react-context-io icon indicating copy to clipboard operation
react-context-io copied to clipboard

implement Context.write without Provider

Open dancerphil opened this issue 6 years ago • 0 comments

我对这个 rfcs 的理解好像和你的实现不同

在你的实现,每次 Context.Provider render 时,都会给 Context 新的 write 函数,如果多 Provider 怎么办?如果 write 修改所有的 Providervalue 就失去了 Provider 分形的意义,如果只修改最后一个被 renderProvider 明显不符合开发者的预期。

react useContextContext.Provider 未给出的时候,会回到 initialValue。我理解,Context.write 可以修改这个 value,但是在这个库,并不能。

我的一部分实现:https://codesandbox.io/s/reactcontextio-example-9361p

dancerphil avatar Jun 06 '19 05:06 dancerphil