Skip to content

Commit

Permalink
Data: Rename useSelect internals to fix React Compiler violations (#6…
Browse files Browse the repository at this point in the history
…6807)

Co-authored-by: tyxla <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent b0d2041 commit 69f71e1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/data/src/components/use-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ function Store( registry, suspense ) {
};
}

function useStaticSelect( storeName ) {
function _useStaticSelect( storeName ) {
return useRegistry().select( storeName );
}

function useMappingSelect( suspense, mapSelect, deps ) {
function _useMappingSelect( suspense, mapSelect, deps ) {
const registry = useRegistry();
const isAsync = useAsyncMode();
const store = useMemo(
Expand Down Expand Up @@ -308,13 +308,11 @@ export default function useSelect( mapSelect, deps ) {
);
}

/* eslint-disable react-hooks/rules-of-hooks */
// `staticSelectMode` is not allowed to change during the hook instance's,
// lifetime, so the rules of hooks are not really violated.
return staticSelectMode
? useStaticSelect( mapSelect )
: useMappingSelect( false, mapSelect, deps );
/* eslint-enable react-hooks/rules-of-hooks */
? _useStaticSelect( mapSelect )
: _useMappingSelect( false, mapSelect, deps );
}

/**
Expand All @@ -337,5 +335,5 @@ export default function useSelect( mapSelect, deps ) {
* @return {ReturnType<T>} Data object returned by the `mapSelect` function.
*/
export function useSuspenseSelect( mapSelect, deps ) {
return useMappingSelect( true, mapSelect, deps );
return _useMappingSelect( true, mapSelect, deps );
}

1 comment on commit 69f71e1

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 69f71e1.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11719956145
📝 Reported issues:

Please sign in to comment.