Skip to content
Discussion options

You must be logged in to vote

@nkleidis instead of stable selector we need to talk about stable selector results, you could have a stable selector that does not return stable results

// Case 1: stable selector result
const prop = useStore(state => state.prop);

// Case 2: stable selector result
const pets = useStore(state => state.pets); // We can use `useShallow` like this `useStore(useShallow(state => state.pets))`
const petNames = pets.map(pet => pet.name)
// Note: you can put this in a custom hook called `usePetNames`

// Case 3: stable selector result
const pets  = useStore(state => state.pets);  // We can use `useShallow` like this `useStore(useShallow(state => state.pets))`
const petsWithExtraInfo = pets.map(pet 

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@nkleidis
Comment options

@dbritto-dev
Comment options

@atraastrum
Comment options

@dai-shi
Comment options

Answer selected by nkleidis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants