-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
install on react ssr #660
Comments
@pedromguerra , can you plz share the whole stack trace here. |
I believe I am getting something similar -- I am using NextJS.
The error triggers every time I type in the editor. Though, the WYSIWYG editor still displays the values as typed. |
It seems that issue is coming while getting selection, that requires DOM it seems. |
A little more context: On load, I get
So
I believe it expects but |
The solution that I have come up with is to set a flag on Also see: facebookarchive/draft-js#796 We can close the issue since this probably has to be addressed in draft-js |
@jakerobers I am having the same issue, can you please share code example how you solved it? I am not sure that I understand how to solve it from your description. It would mean a lot! |
@jelenajjo taken from facebookarchive/draft-js#385 (comment) something like: constructor(props) {
super(props)
this.state = {
editor: false,
}
}
// Once component mounts, enable editor
componentDidMount() {
this.setState({
editor: true
})
}
render() {
const { editor } = this.state
return (
<div className="someComponent">
{ editor
? <DraftEditor />
: null
}
</div>
)
} |
@erikmueller thanks! Works like a charm with Next.js |
It didn't work for me (I'm also using Next.js). I end up using dynamic importing as suggested here: import dynamic from 'next/dynamic'
const Editor = dynamic(() =>
import('react-draft-wysiwyg').then(mod => mod.Editor)
) |
@pdandradeb Nice! I tried with dynamic, but i got this error: "Window is not defined" const Editor = dynamic(
() => {
return import('react-draft-wysiwyg').then((mod) => mod.Editor);
},
{ loading: () => null, ssr: false },
); |
I applied the code above but still getting this error |
@thicodes Thanks a lot! |
I always get this error: client.js:21 Uncaught TypeError: Cannot read property 'getIn' of undefined
after trying to run the editor on server side render react.
what I need to do to run the editor on ssr?
thanks
The text was updated successfully, but these errors were encountered: