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
setState in onChange will block the editor #181
Comments
I have what I think is a similar problem. I put the text content of the editor in the state and set the <AceEditor
value={this.state.text}
onChange={(newValue) => this.textChanged(newValue)}/> This doesn't work properly though. I think that the editor is being re-initialized at each step which isn't much good :( I'm still working exactly what's going on. |
I think that the root of this issue is that if you change the text the component always updates. One solution would be to add a |
or not, apparently I still don't really get this 😁 |
I'm having a similar issue edit: Not sure if this is what @mjmdavis and @dyf102 were experiencing. |
I was always using 'value'. I think I was just being silly. |
Anyone find a solution for this issue? |
I'm having this same issue. |
@mbrochstein I was able to find a workaround by using Reacts shouldComponentUpdate method.
Then for my onChange method for the
This will update the state of aceEditorValue with whatever is entered into the editor without re-rendering the entire component. Works for my use case. |
@brendanmcgivern Thanks! I think you flipped your comparators in the |
What about this one? It works well in my project. THE PARENT COMPONENT // other methods ...
eventMDChange(value) {
let _html = Marked(value)
this.setState({ markdown: value, html: _html })
}
// other methods ... THE EDITOR <AceEditor
onChange={ (raw)=>{this.eventMDChange(raw);} }
value={ this.state.markdown }
/> |
So the issue here is we're tapping into |
Same issue here :/ |
Well, this is a huge bug and it is still there. <AceEditor
mode="yaml"
theme="solarized_light"
onChange={value => {
setFieldValue("content", value);
}}
tabSize={2}
editorProps={{ $blockScrolling: true }}
value={''}
width="100%"
/> upd import React, { Component } from "react";
import { Formik, Form, Field } from "formik";
class AcePlusFormik extends Component {
state = { content: "" };
/**
* Special treatment for ace content
* @param {string} value
*/
setContent(value) {
this.setState({ content: value });
this.setFieldValue("content", value);
}
render() {
<Formik
initialValues={{ title: "", content: "" }}
onSubmit={values => console.log(values)}
>
{({ touched, setFieldValue }) => {
this.setFieldValue = setFieldValue;
return (
<Form>
<Field name="content">
{({ field }) => (
<React.Fragment>
<AceEditor
mode="yaml"
theme="solarized_light"
onChange={value => {
this.setContent(value);
}}
tabSize={2}
editorProps={{ $blockScrolling: true }}
value={this.state.content}
width="100%"
/>
<input type="hidden" {...field} />
</React.Fragment>
)}
</Field>
<button
className="button is-primary is-pulled-right"
style={{ marginTop: "10px" }}
type="submit"
>
Save
</button>
</Form>
);
}}
</Formik>;
}
} |
Are there any solutions or workaround for functional components? It happens when I add props debounceChangePeriod={500} |
The text was updated successfully, but these errors were encountered: