-
Notifications
You must be signed in to change notification settings - Fork 100
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
Editor not displaying at first load with Strictmode #338
Comments
I stuck this in a sandbox for convenience: https://codesandbox.io/s/ecstatic-lamarr-85bjw8?file=/src/index.js You can reproduce the issue by opening the sandbox website in a new tab, any initial load will display the error, but for some reason refreshes won't. The fact that its happening only in strict mode and didn't happen before React 18 probably means it has something to do with the new double invocation behavior described here:
it also means it does not happen in production, more than likely. |
Some more information I've discovered: On the renders the the editor does not initialize, a new |
When the component fails to render properly, this is what the lifecycle looks like (confirmed via logging):
As you can see from those logs, the editor finishes being created, an unmount happens, the process of destroying the watchdog and later the editor begins, |
I am currently fixing this locally by forcing the // In the constructor:
export default class CKEditor extends React.Component {
constructor( props ) {
super( props );
this.destructionInProgress = null;
... // _initializeEditor():
async _initializeEditor() {
if ( this.destructionInProgress ) {
await this.destructionInProgress;
} // componentWillUnmount():
async componentWillUnmount() {
this.destructionInProgress = new Promise( resolve => {
this._destroyEditor().then( () => {
resolve();
} );
} ).then( () => {
this.destructionInProgress = null;
} );
} If these changes seem appropriate, I'll make a pull request with them! If the maintainers have any comments or suggestions though, I'm completely open to changing the implementation and still submitting a pull request. |
Hi @corymharper, thanks for the detailed comments you have written. They explain the problem a bit. We'd appreciate it if you could prepare a PR with these changes. |
Fix: Fixed the component initialization procedure to enforce cleanup completion before subsequent editor initialization. Closes #321. Closes #338. Thanks to @corymharper.
Hello team !
Thank you for your hard work :)
I noticed that my editor wasn't displayed when I start my server (with npm start). To make it showing, I need to reload the page on my navigator, and then it's working fine.
After multiple hours of research I found out that it was occurring because of the React StrictMode. This also comes because I retrieve some data from my own server, and I use useEffect for waiting that all data is loaded before displaying anything.
You can reproduce it in a new React App, with just this code:
Hope you can reproduce it. If you have any questions, do not hesitate;
Thank you for all !
The text was updated successfully, but these errors were encountered: