-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DataViews: Fix field rendering #63452
Conversation
@@ -73,7 +73,7 @@ export type Field< Item > = { | |||
/** | |||
* Callback used to render the field. Defaults to `field.getValue`. | |||
*/ | |||
render?: ( args: { item: Item } ) => ReactNode; | |||
render?: ComponentType< { item: Item } >; |
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.
updating the type actually forces us to use the property properly and prevents us from doing the same error in the future.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +77 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
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.
Thank you!
Co-authored-by: youknowriad <[email protected]> Co-authored-by: ntsekouras <[email protected]>
Related #55083
What?
So it turns out that we were making a noob error when rendering the different fields of the dataviews, while the fields have
render
property that is supposed to be a component, we were not rendering it as a component, instead we were just calling it as a regular function. The problem with that is that if a render property was usinguseSelect
or any other hook, it would result in errors as we enable/disable the fields.The other issue is that it might have had a bad impact on performance potentially as all React and useSelect optimizations were probably ignored.
Testing Instructions
1- Open the "pages" data views
2- Toggle the "author" field on and off
3- it results in an error in trunk but this PR solves the issue.