mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Update use-subscription README (#16216)
It was a little confusing that the question asked when NOT to use this package, then the answer says when to use it. I think this is a little better.
This commit is contained in:
committed by
Brian Vaughn
parent
c0830a0e63
commit
b43785e151
@@ -2,11 +2,11 @@
|
||||
|
||||
React hook that safely manages subscriptions in concurrent mode.
|
||||
|
||||
This utility can be used for subscriptions to a single value that are typically only read in one place and may update frequently (e.g. a component that subscribes to a geolocation API to show a dot on a map).
|
||||
|
||||
## When should you NOT use this?
|
||||
|
||||
This utility should be used for subscriptions to a single value that are typically only read in one place and may update frequently (e.g. a component that subscribes to a geolocation API to show a dot on a map).
|
||||
|
||||
Other cases have **better long-term solutions**:
|
||||
Most other cases have **better long-term solutions**:
|
||||
* Redux/Flux stores should use the [context API](https://reactjs.org/docs/context.html) instead.
|
||||
* I/O subscriptions (e.g. notifications) that update infrequently should use a mechanism like [`react-cache`](https://github.com/facebook/react/blob/master/packages/react-cache/README.md) instead.
|
||||
* Complex libraries like Relay/Apollo should manage subscriptions manually with the same techniques which this library uses under the hood (as referenced [here](https://gist.github.com/bvaughn/d569177d70b50b58bff69c3c4a5353f3)) in a way that is most optimized for their library usage.
|
||||
|
||||
Reference in New Issue
Block a user