question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Editor mount causing react warning "Warning: Cannot update a component from inside the function body of a different component."

See original GitHub issue

Likely due to more recent version of react throwing the warning. As discussed here, (https://github.com/facebook/react/issues/18178) the warning is new and will eventually be a hard exception. I believe the problem comes from this line https://github.com/draft-js-plugins/draft-js-plugins/blob/master/draft-js-plugins-editor/src/Editor/index.js#L74 when onChange callback results in a setState call, resulting in attempt to render the Editor component within its own onMount hook. I suspect this line didn’t work as intended and now the warning brings it to light.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sspreadcommented, May 13, 2020

@lciii Yes its not a react issue. It just surfaced more recently since react started warning about the issue in the plugin that already existed. I’ve outlined the specific problem in my original post.

0reactions
dathackycommented, Nov 18, 2020

Still error 😦( I’m using hook component. const [editorState, setEditorState] = useState( EditorState.createEmpty(decorator), ); Error when use decorator @@

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot update a component from inside the function body of a ...
If you call setState during a render on a different component, you will now see a warning: Warning: Cannot update a component from...
Read more >
Bug: too hard to fix "Cannot update a component from inside ...
React 16.13.0 'Warning: Cannot update a component from inside the function body of a different component.' urql-graphql/urql#600.
Read more >
warning: cannot update a component - You.com | The Search ...
It is happening because useEffect runs after the component is rendered. So what's happening in this case is that your Outlet component is...
Read more >
How to fix the "cannot update a component while rendering a ...
A quick guide to how I solved a confusing React error.
Read more >
Hooks FAQ - React
You can't use Hooks inside a class component, but you can definitely mix classes and function components with Hooks in a single tree....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found