Setting myState from the outside after component is mount will drop the decorators
See original GitHub issuesay you have
<Editor editorState={this.props.myState} onChange={this.onChange} />
After the editor is mounting, if the parent component passes down a new state (through the myState props) to the Editor, the Editor will drop all the plugin decorators, since the decorators are set only during componentWillMount.
Let me know if the explanation is not clear, and I will create a minimal reproduction on jsbin or similar
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:11 (2 by maintainers)
Top Results From Across the Web
How do I manage state outside of React Final Form?
I guess that makes sense. I'm storing the state in the top-most App component. The form itself can be unmounted and re-mounted, but...
Read more >useEffect(fn, []) is not the new componentDidMount()
First, let's talk about the timing of each. componentDidMount runs after the component mounts. As the docs say, if you set state immediately...
Read more >Recovery and Rebirth: The Age of the Renaissance
n How did the fall of Constantinople to the Ottoman Turks lead to changes in trade, diplomacy, and society after 1453?
Read more >A Guide to USPS Mailbox Regulations - Mailboss
Guide to USPS regulations for mailbox installation of curbside mailboxes, locking mail boxes, wall mount units and residential package ...
Read more >Installing a Garage Heater : 8 Steps - Instructables
1. Ideally, you would want to position the heater in the coldest location in the garage at a 45 degree angle aimed at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My temporary solution is to call
componentWillMount()
on my<Editor>
instance becausecomponentWillMount
is where all of the decorators are resolved and merged into the editor state.I’m calling the following in my container component’s
componentWillReceiveProps
so that I can update the editor state in response to next props:Assuming the following:
https://github.com/draft-js-plugins/draft-js-plugins/pull/526 attempted to add a
reloadDecorators
method to the<Editor>
component which accomplishes the end result. However, I think that this should just work for users for this library. Apparently, simply resolving the decorators and merging them into the editor state incomponentWillMount
is not enough. However, doing it incomponentWillReceiveProps
is probably too much and I’ve observed it doing strange things with the cursor.My specific use case: I have a single page application that lists available docs and allows users to click on a doc to view/edit. When a user loads the app on a doc route, the decorators are all intact and the doc renders correctly. However, if the user loads the app on the docs route or navigates away from a doc route and back to another doc route (essentially, after the initial instance of the doc component in unmounted), many decorators are missing, such as linkify, link, mention, emoji, images, etc.
@gnestor yes exactly
My temporary solution looks very similar:
Unfortunately I have no other ideas to fix my problem.