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 Plugin doesn't react to a new editorState

See original GitHub issue

when changing the editorState such as re-setting with EditorState.createEmpty(), a user would expect the plugin editor to react to the change in state as DraftJS’s Editor does. But the plugin editor only binds the decorators in componentWillMount so the editor loses the plugins

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
mjrussellcommented, May 16, 2016

declare it as bad practice (which I think it is) & log a info with a link to a detailed explanation.

I think this would be the wrong thing to do, considering that the draft-js regular editor works this way, I think its going to confuse users to not be able to do this. It also seems to violate the API that appears to be a controlled component (i.e. onChange with the editorState as a value).

check for an updated editorState in the componentWillReceiveProps

I think this is actually pretty easy. Should be able to just compare this.props.editorState with nextProps.editorState and add the decorators to the new editorState if they differ. Only warning I would add is if the decorator object is already defined

Also Related to #251 and #256

0reactions
whitef0x0commented, Mar 31, 2017

@nikgraf any update on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple draft-js-plugins editors on the same page don't work
I'm trying to use multiple rich text editors in a React form. I built the editor component using draft ...
Read more >
Reference manual - ProseMirror
This module implements the state object of a ProseMirror editor, along with the representation of the selection and the plugin abstraction. Editor State....
Read more >
EditorState - Draft.js
Returns a new EditorState object with the selection at the end. Moves selection to the end of the editor without forcing focus. moveFocusToEnd...
Read more >
Draft-js - Saving data to the server - React Rocket
If you're fairly new to draft.js you should check out at least the 1st one ... import { EditorState, Editor, convertToRaw } from...
Read more >
Reference Manual - CodeMirror
class EditorState. The editor state class is a persistent (immutable) data structure. To update a state, you create a transaction, which produces a...
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