Skip to content

Commit

Permalink
fix: flushSync problem (#2581)
Browse files Browse the repository at this point in the history
* fix: fix flushSync problem

* Spotless Apply

---------

Co-authored-by: leechor <[email protected]>
  • Loading branch information
leechor and leechor authored Nov 29, 2023
1 parent e38c814 commit ccf84ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions dinky-web/src/hooks/useEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
useEffect,
useState
} from 'react';
import { flushSync } from 'react-dom';
import { useModel } from 'umi';
export interface FullScreenContextProps {
fullscreen: boolean;
Expand All @@ -44,12 +43,10 @@ export const FullScreenProvider: FC = memo(({ children }: any) => {
const { initialState, setInitialState } = useModel('@@initialState');

useEffect(() => {
flushSync(() => {
setInitialState((s) => ({
...s,
fullscreen
}));
});
setInitialState((s) => ({
...s,
fullscreen
}));
}, [fullscreen]);
return (
<FullScreenContext.Provider value={{ fullscreen, setFullscreen }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default () => {
>
{l('button.heartbeat')}
</Button>
</Authorized>,
</Authorized>
];

const renderListItem = (item: Cluster.Instance) => {
Expand Down

0 comments on commit ccf84ae

Please sign in to comment.