top | item 17980340

(no title)

haukur | 7 years ago

I haven't seen any libraries using the new context API make use of the observedBits prop (currently called `unstable_observedBits`, as its not officially supported). There's a comment in this library's codebase that hints that it will be used in the future. I wrote a bit about this API bitmask-based API a few months ago while I was experimenting with it[1], so I'm curious about its current state and whether others have experimented with it or know about its future in general.

[1] https://hph.is/coding/bitmasks-react-context

discuss

order

acemarke|7 years ago

I'm _specifically_ hoping to use it in React-Redux v6.x, and wrote up a very extended description a couple days ago of why and how I hope to use it:

https://github.com/reduxjs/react-redux/issues/1018

I actually referenced your blog post as a good overview of how to use the bitmask API, so thanks for writing it!

I also filed a React RFC to make the API a bit more flexible by allowing us to pass a `calculateChangedBits` function directly to a `Context.Provider` instance:

https://github.com/reactjs/rfcs/pull/60

Sebastian Markbage replied in that RFC thread, and tbh the discussion seemed a bit odd. It seemed like he was discouraging me from trying to use the bitmask API, or trying to figure out why I might actually want to use it, when it seems like the entire reason it exists is exactly for something like React-Redux to leverage it for performance optimizations.

Aweary|7 years ago

I had a few versions of react-copy-write working with `unstable_observedBits` but I couldn't decide on the right optimization strategy. At this point I'm not sure how likely it is that this API will be released as stable, so I'm going to hold off until thats more clear.