udecode / zustand-x

Zustand store factory for a best-in-class developer experience.
https://zustand-x.udecode.dev
MIT License
328 stars 20 forks source link

[Feat]: selector hooks support passing equality function #34

Closed ShinyLeee closed 2 years ago

ShinyLeee commented 2 years ago

Description

Auto generated selector hooks currently not support prevent re-render, i think it's better to implement it.

Example

import shallow from 'zustand/shallow'

const repoStore = createStore('repo')({
  name: 'zustood ',
  stars: 0,
  middlewares: ['immer', 'devtools', 'persist']
})

// prevent unnecessary re-renders
// more see: https://docs.pmnd.rs/zustand/recipes#selecting-multiple-state-slices
useStore().repo.middlewares(shallow)

// or
useStore().repo.middlewares((prev, next) => prev.middlewares === next.middlewares)
changeset-bot[bot] commented 2 years ago

🦋 Changeset detected

Latest commit: 2660088fddc62fc23bae0ef58a2cae2e50ca1bc9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---------------- | ----- | | @udecode/zustood | Major |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR