-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Refactored PostTextEditor to use React Hook #23897
Refactored PostTextEditor to use React Hook #23897
Conversation
Hi @ntsekouras. When you have time, could you have another look at this pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I left some small comments but I tested it and seems to be okay.
My main concern was about the getDerivedStateFromProps
change. After consulting @youknowriad he noted these very useful things:
I think the difficulty in this component is due to the fact that we want:
- Changes to the blocks (or the content property) in the store to reflect immediately in the editor
- Changes in the editor to only change the blocks property when persisting and avoid parsing/serialization on each key strike
Reading the previous code getDerivedStateFromProps it seems to be used to update the state value (the rendered value) of the text editor when external changes happen (prop value changes) but only if we’re not editing the textarea (isdirty state)
I don’t think we should be too strict with keeping the exact same logic, but it’s definitely a fragile component that needs to be tested properly. (Autosaves should not impact editing, clearing the textarea should be possible, switching after edits updates the visual editor, clicking save after edits reflects the edits in the saved content, post is not dirty until we make an edit)
I have tested all the above and it LGTM compared to previous functionality on master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work @javidalkaruzi 👍
Description
See #22890
Refactored PostTextEditor to use React Hook.
How has this been tested?
Tested using existing unit tests.
Checklist: