fix: fix the moment to delete provider

pull/31/head
fantasticit 2022-05-02 17:29:22 +08:00
parent 344cc5b05c
commit 5540c0dfab
2 changed files with 9 additions and 16 deletions

View File

@ -65,6 +65,9 @@ export const Editor: React.FC<IProps> = ({ user: currentUser, documentId, author
onSynced() {
toggleLoading(false);
},
onStatus({ status }) {
setStatus(status);
},
},
});
}, [documentId, currentUser, toggleLoading]);
@ -85,22 +88,15 @@ export const Editor: React.FC<IProps> = ({ user: currentUser, documentId, author
//
}
}, 50),
onDestroy() {
destoryProvider(provider, 'EDITOR');
},
},
[authority, provider]
);
const [mentionUsersSettingVisible, toggleMentionUsersSettingVisible] = useToggle(false);
const [mentionUsers, setMentionUsers] = useState([]);
useEffect(() => {
provider.on('status', async ({ status }) => {
setStatus(status);
});
return () => {
destoryProvider(provider, 'EDITOR');
};
}, [documentId, provider, authority]);
useEffect(() => {
if (!authority || !authority.editable) return;

View File

@ -64,13 +64,10 @@ export const Editor: React.FC<IProps> = ({ user, documentId, document, children
// @ts-ignore
taskItemClickable: true,
},
});
useEffect(() => {
return () => {
onDestroy() {
destoryProvider(provider, 'READER');
};
}, [provider]);
},
});
return (
<DataRender