Skip to content

Commit

Permalink
Cleanup with Promise instead of setTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Mar 8, 2023
1 parent 20156b9 commit 951473b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion code/ui/blocks/src/components/Story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const InlineStory: FunctionComponent<InlineStoryProps> = (props) => {
return () => {
// It seems like you are supposed to unmount components outside of `useEffect`:
// https://github.com/facebook/react/issues/25675#issuecomment-1363957941
setTimeout(() => cleanup(), 0);
Promise.resolve().then(() => cleanup());
};
}, [autoplay, renderStoryToElement, story]);

Expand Down

0 comments on commit 951473b

Please sign in to comment.