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
onChange function is cached #297
Comments
I have the same problem. |
@avalero Can you provide a complete example? |
Hello @jaywcjlove , yes, this is a working Component that shows this behaviour
Whenever I write on the MDEditor |
@avalero @eleven-huang I think this problem is solved perfectly. |
Great @jaywcjlove , thanks for your time and effort!! |
Great work @jaywcjlove |
The
onChange
prop function of theMDEditor
component is cached (due to theuseReducer
), and thus data passed is taken as closure, not updating when component re-renders.For example, for this code
Problem happens if I update
number
-->setData({...data, number: 5})
When MDEditor changes,
number
is reset to0
, becauseonChange
function is cached withdata
being{text:"", value: 0}
I hope I have made myself clear. If not I can push a full component example of this problem.
The text was updated successfully, but these errors were encountered: