Skip to content
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

Convert BlockHTML component from class component to React hooks #18968

Merged
merged 2 commits into from Dec 6, 2019

Conversation

@youknowriad
Copy link
Contributor

youknowriad commented Dec 6, 2019

Just a small refactoring PR that shouldn't have any impact aside improving our code quality and following the last guidelines (prefer react hooks)

Testing instructions

Ensure that "Edit HTML" works as before.

@youknowriad youknowriad requested review from ellatrix and talldan as code owners Dec 6, 2019
@youknowriad youknowriad self-assigned this Dec 6, 2019
};

useEffect( () => {
setHtml( getBlockContent( block ) );

This comment has been minimized.

Copy link
@ellatrix

ellatrix Dec 6, 2019

Member

I notice before that there was an isEqual check. Do you remember why? Does it make sense here?

This comment has been minimized.

Copy link
@youknowriad

youknowriad Dec 6, 2019

Author Contributor

I think it's not necessary because the useState hook won't rerender if we end up with the same html content.

This comment has been minimized.

Copy link
@ellatrix

ellatrix Dec 6, 2019

Member

But the useEffect hook will still be called? I guess it's ok to re-set the HTML?

@youknowriad

This comment has been minimized.

Copy link
Contributor Author

youknowriad commented Dec 6, 2019

I removed the previous test because it was testing the implementation details and not really the behavior.

@youknowriad youknowriad merged commit 10596a5 into master Dec 6, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
@youknowriad youknowriad deleted the update/convert-block-html branch Dec 6, 2019
@youknowriad youknowriad added this to the Gutenberg 7.1 milestone Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.