Skip to content

Commit

Permalink
fix: migrating to React 18
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-y committed Jan 9, 2025
1 parent 9985ccb commit b79fdfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions nerdlets/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const HomeNerdlet = () => {
loading: flowsLoading,
refetch: flowsRefetch,
} = useFlowLoader({ accountId });
const { data: accounts = [] } = useAccountsQuery();
const { data: accounts = [], loading: isAcctsLoading } = useAccountsQuery();
const transitionTimeoutId = useRef();

useEffect(() => {
Expand All @@ -85,8 +85,8 @@ const HomeNerdlet = () => {
};
}, []);

useEffect(
() =>
useEffect(() => {
if (!isAcctsLoading) {
setApp({
account: {
id: accountId,
Expand All @@ -96,9 +96,9 @@ const HomeNerdlet = () => {
debugMode,
maxEntitiesInStep: MAX_ENTITIES_IN_STEP,
user,
}),
[accountId, accounts, user, debugMode]
);
});
}
}, [accountId, accounts, user, debugMode, isAcctsLoading]);

useEffect(() => {
let actionControlButtons;
Expand Down
10 changes: 9 additions & 1 deletion src/components/flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const Flow = forwardRef(
label: 'Starting playback...',
});
const [isPreview, setIsPreview] = useState(false);
const [activateTransition, setActivateTransition] = useState(false);
const {
account: { id: accountId } = {},
debugMode,
Expand Down Expand Up @@ -141,9 +142,16 @@ const Flow = forwardRef(
component: FLOW_DISPATCH_COMPONENTS.FLOW,
saveFlow,
});
if (onTransition && prevNonEditMode) onTransition(prevNonEditMode);
setActivateTransition(true);
};

useEffect(() => {
if (activateTransition) {
if (onTransition && prevNonEditMode) onTransition(prevNonEditMode);
setActivateTransition(false);
}
}, [activateTransition]);

const discardFlowHandler = useCallback(() => {
setIsPreview(false);
if (onTransition) onTransition(prevNonEditMode);
Expand Down

0 comments on commit b79fdfe

Please sign in to comment.