-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Strict Mode: Error: It looks like renderHandlers were already set by someone else. #264
Comments
EDIT: Added a link to my working example below I do have a PR open to fix this issue, but for those of us that want to keep using For those curious as to why this issue only occurs in WorkaroundJavascript being the wonderfully messed up language it is allows us to do the following. Typescriptimport { BangleEditor, useEditorState } from '@bangle.dev/react';
((has) => {
WeakMap.prototype.has = function (key: WeakKey) {
if (key instanceof HTMLDivElement && key.parentElement?.id === 'bangle-editor') return false;
return has.bind(this)(key);
};
})(WeakMap.prototype.has);
export function Editor() {
const state = useEditorState({
// ...
});
return (
<div id="bangle-editor">
<BangleEditor state={state} />
</div>
);
} Javascriptimport { BangleEditor, useEditorState } from '@bangle.dev/react';
((has) => {
WeakMap.prototype.has = function (key) {
if (key instanceof HTMLDivElement && key.parentElement?.id === 'bangle-editor') return false;
return has.bind(this)(key);
};
})(WeakMap.prototype.has);
export function Editor() {
const state = useEditorState({
// ...
});
return (
<div id="bangle-editor">
<BangleEditor state={state} />
</div>
);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The editor crashes with React 18 in development only, with the most basic setup. When building for production it works as expected.
Using
UPDATE: It only crashes when
<React.StrictMode>
is usedThe text was updated successfully, but these errors were encountered: