Skip to content

Can I bind only relevant data to a component? #127

Closed Answered by dai-shi
johnsonthedev asked this question in Q&A
Discussion options

You must be logged in to vote

First things first, you need to use the snapshot. const snap = useSnapshot(store)

Dealing with the array is kind of hard. Best is:

  • use React.memo
  • and only pass primitive values
  • useSnapshot in each child component if you don't want to get all primitive values in props

For example: https://codesandbox.io/s/angry-bouman-belio?file=/src/App.js

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by johnsonthedev
Comment options

You must be logged in to vote
2 replies
@dai-shi
Comment options

@johnsonthedev
Comment options

Comment options

You must be logged in to vote
1 reply
@dai-shi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants