Skip to content

Commit

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

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 );
}

0 comments on commit 69f71e1

Please sign in to comment.