Skip to content

Docs: Check if done resolving first in authors example of dataviews#65246

Open
Shelob9 wants to merge 2 commits intoWordPress:trunkfrom
Shelob9:patch-9
Open

Docs: Check if done resolving first in authors example of dataviews#65246
Shelob9 wants to merge 2 commits intoWordPress:trunkfrom
Shelob9:patch-9

Conversation

@Shelob9
Copy link
Copy Markdown
Contributor

@Shelob9 Shelob9 commented Sep 11, 2024

What?

  • I got error, pasted below when trying this example.
normalize-fields.js:14 Uncaught TypeError: Cannot read properties of undefined (reading 'map')
    at normalizeFields (normalize-fields.js:14:1)
    at index.js:54:48
    at mountMemo (react-dom.js?ver=18.3.1:16416:21)
    at Object.useMemo (react-dom.js?ver=18.3.1:16861:18)
    at useMemo (react.js?ver=18.3.1:1640:23)
    at DataViews (index.js:54:26)
    at renderWithHooks (react-dom.js?ver=18.3.1:15496:20)
    at mountIndeterminateComponent (react-dom.js?ver=18.3.1:20113:15)
    at beginWork (react-dom.js?ver=18.3.1:21636:18)
    at HTMLUnknownElement.callCallback (react-dom.js?ver=18.3.1:4151:16)
  • index.js:54 is const _fields = useMemo(() => normalizeFields(fields), [fields]); in @wordpress/dataviews/build-module/components/dataviews/index.js

Why?

  • This fixed it by waiting until data has loaded

How?

  • Update docs

@github-actions
Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Shelob9 <shelob9@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

const { records } = useEntityRecords( 'postType', 'page', queryArgs );
const { records,isResolving,totalItems,totalPages } = useEntityRecords( 'postType', 'page', queryArgs );

if ( isResolving ){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! It seems that the docs have only partial DataViews per supported property and it doesn't seem very useful to update just one of them.

Maybe it's better to add a minimal example that users can copy/paste and test.

It's been while since this PR was opened, but are you open to updating the PR to have such an example?

@ntsekouras ntsekouras added [Type] Developer Documentation Documentation for developers [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants