diff --git a/docs/recipes/recipes.mdx b/docs/recipes/recipes.mdx index b58d62eb77..ce12ef2eeb 100644 --- a/docs/recipes/recipes.mdx +++ b/docs/recipes/recipes.mdx @@ -65,29 +65,6 @@ const currentBear = useCredentialsStore((state) => state.currentBear) const bear = useBearStore((state) => state.bears[currentBear]) ``` -## Memoizing selectors - -It is generally recommended to memoize selectors with `useCallback`. -This will prevent unnecessary computations each render. -It also allows React to optimize performance in concurrent mode. - -```jsx -const fruit = useStore(useCallback((state) => state.fruits[id], [id])) -``` - -If a selector doesn't depend on scope, -you can define it outside the render function -to obtain a fixed reference without `useCallback`. - -```jsx -const selector = (state) => state.berries - -function Component() { - const berries = useStore(selector) - // ... -} -``` - ## Overwriting state The `set` function has a second argument, `false` by default.