-
Notifications
You must be signed in to change notification settings - Fork 930
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
Unable to access Editor instance with dynamically imported react-quill in NextJS #642
Comments
have you found a solution for this. I am also experiencing this issue as well. |
@jularbs I have not. |
Are you trying to do this in server-side render (SSR) mode? If so, does NextJS provide a window.document object? You can't SSR React-Quill without it. |
I am not an expert on Next, but it looks like this creates a dynamic component wrapper around ReactQuill. const ReactQuill = dynamic(() => import("react-quill"), {
ssr: false
}); When you render it, it's not giving you a ref to RQ, it's a ref to the wrapper that Next creates: <ReactQuill ref={quillRef} theme="snow" value={value} onChange={setValue} /> Here is an issue on the Next side that describes some potential solutions. Can you try one of them and see if it works for you? |
Perhaps we could switch into this: https://www.npmjs.com/package/react-quilljs Code example: https://codesandbox.io/s/laughing-surf-ox7q5 |
When https://codesandbox.io/s/nextjs-dynamic-react-quill-ref-example-forked-gyhz3 |
but what about tsx file in next.js? your codesandbox is js |
With TS const ReactQuillComponent = dynamic(
async () => {
const { default: RQ } = await import('react-quill');
const Component = ({ forwardedRef, ...props }: { forwardedRef: RefObject<ReactQuill> } & ReactQuillProps) => (
<RQ ref={forwardedRef} {...props} />
);
Component.displayName = 'ReactQuillComponent';
return Component;
},
{
ssr: false,
}
);
ReactQuillComponent.displayName = 'ReactQuillComponent';
); |
brooooo 🙌🏻 |
I'm using react-quill in a NextJS app. I'm looking to extend a part of the app where I want to force users to use the Quill instance with a specific formatting option enabled by default (list). To achieve this, I believe I need access to the Quill Editor instance.
However, when attempting to use a ref, I'm unable to call the getEditor method on the ref. The only method available is
retry
.I've made a CodeSandbox: https://codesandbox.io/s/nextjs-dynamic-react-quill-ref-example-sxm64
Check the browser console to see what the ref object is.
Expected behavior:
I would expect the ref to contain a
getEditor
methodActual behavior:
The ref only contains a
retry
methodVersion:
2.0.0-beta.2
The text was updated successfully, but these errors were encountered: