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

Refactor ReadableContentView component into a custom hook #5614

Closed
geriux opened this issue Mar 30, 2023 · 0 comments · Fixed by WordPress/gutenberg#49616
Closed

Refactor ReadableContentView component into a custom hook #5614

geriux opened this issue Mar 30, 2023 · 0 comments · Fixed by WordPress/gutenberg#49616
Assignees

Comments

@geriux
Copy link
Contributor

geriux commented Mar 30, 2023

Currently, the ReadableContentView component is responsible for handling the max width of the canvas and providing alignment styles based on the window screen and the align prop. However, we want to refactor this functionality into a custom hook instead.

The new custom hook will use the useWindowDimensions hook to get the window width and height, and will take the align prop into account when calculating the alignment styles and canvas max width. It will return an object with the styles and canvas max width for the given align prop.

By using the useWindowDimensions hook, we can also reduce the number of listeners in the code and make it more efficient since we are currently adding dimension listeners within this component.

To implement this change, we will remove the ReadableContentView component and replace its usage with the new custom hook. We will also update any tests or other components that rely on ReadableContentView.

It will also remove nesting two extra Views since we often encounter an issue where nesting too many Views crashes the editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant