react-context-io
react-context-io copied to clipboard
implement Context.write without Provider
我对这个 rfcs 的理解好像和你的实现不同
在你的实现,每次 Context.Provider render 时,都会给 Context 新的 write 函数,如果多 Provider 怎么办?如果 write 修改所有的 Provider 的 value 就失去了 Provider 分形的意义,如果只修改最后一个被 render 的 Provider 明显不符合开发者的预期。
react useContext 在 Context.Provider 未给出的时候,会回到 initialValue。我理解,Context.write 可以修改这个 value,但是在这个库,并不能。
我的一部分实现:https://codesandbox.io/s/reactcontextio-example-9361p