Skip to content

Is this a good practice? #85

Answered by lostpebble
joelbqz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @joelbqz ,

So, the only issue that I see here is that you would be creating multiple subscriptions which will be individually listening on each of those keys. This isn't generally the most effective way to do things- its better to define your Store.useState() listener once for all the required state.

The main issue would be if React will batch those updates (if you are listening to, and change more than one value at the same time). Currently it might not be so, and you might have to wrap your store updates in something like

ReactDOM.unstable_batchedUpdates(() => { // do updates here });

Though this is an unstable API and might change in React in the future. React also does do some aut…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@joelbqz
Comment options

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