react-activation icon indicating copy to clipboard operation
react-activation copied to clipboard

context初值不能为undefined

Open VeronicaF opened this issue 3 years ago • 4 comments

不是很明白为什么这里要判断值不是undefined,如果将context初始值设为undefined会报错

https://github.com/CJY0208/react-activation/blob/4fb793fd7de50af8e7220503d243c116bb7be241/src/core/Bridge/Context/ConsumerWrapper.js#L11-L17

VeronicaF avatar May 26 '21 05:05 VeronicaF

这里造成的问题是如果 context 上下文初始值为 undefined,后续更新就无法桥接了对吗?

CJY0208 avatar May 26 '21 08:05 CJY0208

sorry,没有通读代码不太明白桥接的意思。

代码层面来看,会导致ConsumerWrapper的递归中那一层的this.ctxInfonull,也即没有初始化,而后续context的值更新,不再是undefined,进而导致null被传递进某一层的ProviderBridge,被使用时触发报错。

image

VeronicaF avatar May 26 '21 09:05 VeronicaF

一直忘记这个问题了...现在看好像还存在,暂时先留着...

CJY0208 avatar Jun 29 '22 09:06 CJY0208

什么时候解决一下?

Noah-JJ avatar Nov 24 '22 01:11 Noah-JJ