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.

The value of the editor is not updated

See original GitHub issue

I have an issue in my app where I’m using the editor.

I use the editor in a CMS like applications. There is no issue in the first use of the editor in the app, the init value is correct. But when I change the current “edited page”, the field still displayed the old value (previous edited page). I still can edit the editor, and it’s ok, but the “init value” is wrong.

The value is correctly set as you can see in the screenshot but the value displayed is wrong. I tried many things but I failed to solve this.

Could you help me on that?

Here is a screenshot (as you can see the input above the editor works properly, it’s not a react issue)

Here is the code:

          <SimpleMDE
            onChange={this.props.setArticleDescription}
            value={content.description}
            options={{
              autoDownloadFontAwesome: false,
              hideIcons: [
              ...
              ],
              spellChecker: false,
              status: false
            }}
          />

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
haenchcommented, Feb 11, 2019

Hi,

I ran into the same issue: I think it is realted to componentDidUpdate this part

    if (
      !this.state.keyChange &&
      this.props.value !== this.state.value && // This is somehow fixes moving cursor for controlled case
      this.props.value !== prevProps.value // This one fixes no value change for uncontrolled input. If it's uncontrolled prevProps will be the same
    ) {
      this.simpleMde!.value(this.props.value || "");
    }

the state is not correctly updated when props change.

A simple trick solved the issue: I provided a key attribute with a unique id. Thats makes sure the component is rerendered on props change (I think): <SimpleMDEReact key={unique_id} value={my_value} onChange={value => onChange} />

1reaction
patmoodcommented, Jan 17, 2020

This bug depends if the component is controlled or uncontrolled and any solutions should test both cases.

I’m using it as a controlled component and fixed the issue by removing all references to state, since it’s not required. I’ll try creating a PR that handles both cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PrimeFaces Editor not updating value - jsf - Stack Overflow
xhtml. Now, if I write something on the editor, the value of the editor is not updated in the backing bean.
Read more >
Editing field using list editor does not update va... - ServiceNow
I have an issue regarding List Editor. Changing the value of a field in List Editor in Related List in a Record does...
Read more >
Unable to update the data value: Value in the editor is not valid
Hi,. I have a grid with Name. StartDate & Enddate. Ex. Nov.13 01/11/2013 30/11/2013. When i accidentally entered a value for Enddate for ......
Read more >
The content of the Editor is not properly updated when the ...
The content of the Editor is not properly updated when the component is hosted in the TelerikForm. If a TelerikEditor and TextArea are...
Read more >
New value in inline editor not updating when hitting enter
I have the inline editor extension, and when i edit a field and press enter, the ajax works, it saves the data, but...
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