Skip to content

Commit

Permalink
Capture state changes before useSelect subscription
Browse files Browse the repository at this point in the history
In the event that a child component dispatched an action modifying the
store, the changes in the store were lost due to `useSelect`'s
`useIsomorphicLayoutEffect` referencing a stale value.

This change ensures the `useIsomorphicLayoutEffect` references the
latest `mapOutput` when setting the related `latestMapOutput.current`
value.
  • Loading branch information
dcalhoun committed Feb 4, 2022
1 parent 6553e2c commit ac63fd5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/data/src/components/use-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default function useSelect( mapSelect, deps ) {
latestIsAsync.current = isAsync;
renderQueue.flush( queueContext );
}
} );
}, [ mapOutput ] );

useIsomorphicLayoutEffect( () => {
if ( ! hasMappingFunction ) {
Expand Down

0 comments on commit ac63fd5

Please sign in to comment.