You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's easy to incorrectly use partitions. You probably want a useStateProperty, which reads and writes to a single keyed property like React.useState rather than creating a whole store partition just for one property.
Given the overhead of a store structure and the potential memory leaks, it's easy to get partitions wrong in react. Creating a partition creates a long-lived listener on a store which you can't unsubscribe, and which has its own listener infrastructure. See #35 for how tempting using partitions looks.
For example this will create a new store every time the key changes, and they will just build up as listeners to the ancestor store, creating a memory leak.
As part of usePartition, perhaps a partition destroy() operation is needed that unsubscribes the partition and deliberately breaks all the operations which are no longer 'live' after unsubscribing. A usePartition hook would look after destroying partitions as well as creating them.
The text was updated successfully, but these errors were encountered:
It's easy to incorrectly use partitions. You probably want a useStateProperty, which reads and writes to a single keyed property like
React.useState
rather than creating a whole store partition just for one property.Given the overhead of a store structure and the potential memory leaks, it's easy to get partitions wrong in react. Creating a partition creates a long-lived listener on a store which you can't unsubscribe, and which has its own listener infrastructure. See #35 for how tempting using partitions looks.
For example this will create a new store every time the key changes, and they will just build up as listeners to the ancestor store, creating a memory leak.
As part of usePartition, perhaps a partition destroy() operation is needed that unsubscribes the partition and deliberately breaks all the operations which are no longer 'live' after unsubscribing. A usePartition hook would look after destroying partitions as well as creating them.
The text was updated successfully, but these errors were encountered: