fix: effect deps (#1940)

This commit is contained in:
Himself65 2023-04-14 00:24:44 -05:00 committed by GitHub
parent d58f9db289
commit 5ca94db5d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 22 additions and 15 deletions

View File

@ -4,3 +4,4 @@ dist
out
storybook-static
affine-out
_next

View File

@ -10,6 +10,7 @@ module.exports = {
},
extends: [
'eslint:recommended',
'plugin:react-hooks/recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:@typescript-eslint/recommended',

View File

@ -58,6 +58,7 @@
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"fake-indexeddb": "4.0.1",

View File

@ -50,7 +50,7 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
}
props.onLoad?.(page, editor);
}
}, [props.page, props.onInit, props.onLoad]);
}, [props.page, props.onInit, props.onLoad, editor, props, page]);
const ref = useRef<HTMLDivElement>(null);

View File

@ -53,10 +53,10 @@ export const AffineSharePage: FC<ShareMenuProps> = props => {
}, [props.workspace.id, props.currentPage.id]);
const onClickCreateLink = useCallback(() => {
setIsPublic(true);
}, [isPublic]);
}, [setIsPublic]);
const onClickCopyLink = useCallback(() => {
navigator.clipboard.writeText(sharingUrl);
}, []);
}, [sharingUrl]);
return (
<div className={menuItemStyle}>

View File

@ -32,7 +32,7 @@ export const PublicLinkDisableModal = ({
portal: document.body,
});
onClose();
}, []);
}, [onClose, setIsPublic]);
return (
<Modal open={open} onClose={onClose}>
<StyledModalWrapper>

View File

@ -78,7 +78,7 @@ const TreeNodeItemWithDnd = <RenderProps,>({
if (isOver && canDrop) {
setCollapsed(node.id, false);
}
}, [isOver, canDrop]);
}, [isOver, canDrop, setCollapsed, node.id]);
return (
<TreeNodeItem

View File

@ -60,7 +60,7 @@ export const TreeView = <RenderProps,>({
document.removeEventListener('keydown', handleDirectionKeyDown);
document.removeEventListener('keydown', handleEnterKeyDown);
};
}, [data, selectedId]);
}, [data, enableKeyboardSelection, onSelect, selectedId]);
const setCollapsed: TreeNodeProps['setCollapsed'] = (id, collapsed) => {
if (disableCollapse) {

View File

@ -43,6 +43,6 @@ export function useBlockSuiteWorkspaceAvatarUrl(
dispose.dispose();
};
}
}, []);
}, [blockSuiteWorkspace]);
return [avatar ?? null, setAvatar] as const;
}

View File

@ -13,12 +13,15 @@ export function useBlockSuiteWorkspacePageIsPublic(page: Page) {
page.workspace.meta.pageMetasUpdated.on(() => {
set(page.meta.isPublic ?? false);
});
}, []);
const setIsPublic = useCallback((isPublic: boolean) => {
set(isPublic);
page.workspace.setPageMeta(page.id, {
isPublic,
});
}, []);
}, [page]);
const setIsPublic = useCallback(
(isPublic: boolean) => {
set(isPublic);
page.workspace.setPageMeta(page.id, {
isPublic,
});
},
[page.id, page.workspace]
);
return [isPublic, setIsPublic] as const;
}

View File

@ -7426,6 +7426,7 @@ __metadata:
eslint-plugin-import: ^2.27.5
eslint-plugin-prettier: ^4.2.1
eslint-plugin-react: ^7.32.2
eslint-plugin-react-hooks: ^4.6.0
eslint-plugin-simple-import-sort: ^10.0.0
eslint-plugin-unused-imports: ^2.0.0
fake-indexeddb: 4.0.1
@ -10618,7 +10619,7 @@ __metadata:
languageName: node
linkType: hard
"eslint-plugin-react-hooks@npm:^4.5.0":
"eslint-plugin-react-hooks@npm:^4.5.0, eslint-plugin-react-hooks@npm:^4.6.0":
version: 4.6.0
resolution: "eslint-plugin-react-hooks@npm:4.6.0"
peerDependencies: