Skip to content

Get() method from store does not force rerender #2358

Answered by dbritto-dev
bruno-teruel asked this question in Q&A
Discussion options

You must be logged in to vote

@bruno-teruel what about this:

const getBearsPlusFive = (bears) => bears + 5

const useBearStore = create()((set, get) => ({
  bears: 0,
}))

const BearComponent = (props) => {
  const bears = useBearStore((state) => state.bears)
  const bearsPlusFive = getBearsPlusFive(bears)
  return <p>{bearsPlusFive}</p>
}

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@mkf62
Comment options

@mkf62
Comment options

@dbritto-dev
Comment options

Answer selected by bruno-teruel
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants