一旦我更新了 mobx 5,KonvaJs 示例就不起作用
KonvaJs example does not work once i updated mobx 5
我正在尝试开发 KonvaJs 示例:https://konvajs.org/docs/sandbox/Window_Frame_Designer.html
克隆存储库时一切正常。但是,一旦我将 mobx 从 4.3.1 更新到 5.15.0,它就会出现该错误;
Error: MobX injector: Store 'store' is not available! Make sure it is provided by some Provider
谁能帮我解决这个问题。
谢谢
看起来 mobx-react
正在使用 React 上下文将 store
传递给组件。
但是 React Context 不会自动为自定义 React 渲染器(例如 react-konva
)工作。有关详细信息,请参阅:https://github.com/konvajs/react-konva/issues/188
作为解决方法,您只需要 "bridge" 存储在 <Stage>
组件中:
<Stage
width={this.state.width}
height={height}
ref={ref => {
this.stageRef = ref;
}}
onClick={this.handleClick}
>
<Provider store={this.props.store}>
<Layer scaleX={scale} scaleY={scale} y={20} x={20}>
<Section
section={root.sections[0]}
x={root.frameSize}
y={root.frameSize}
/>
<Sash
width={root.width}
height={root.height}
size={root.frameSize}
/>
<Metrics />
</Layer>
</Provider>
</Stage>
我正在尝试开发 KonvaJs 示例:https://konvajs.org/docs/sandbox/Window_Frame_Designer.html
克隆存储库时一切正常。但是,一旦我将 mobx 从 4.3.1 更新到 5.15.0,它就会出现该错误;
Error: MobX injector: Store 'store' is not available! Make sure it is provided by some Provider
谁能帮我解决这个问题。 谢谢
看起来 mobx-react
正在使用 React 上下文将 store
传递给组件。
但是 React Context 不会自动为自定义 React 渲染器(例如 react-konva
)工作。有关详细信息,请参阅:https://github.com/konvajs/react-konva/issues/188
作为解决方法,您只需要 "bridge" 存储在 <Stage>
组件中:
<Stage
width={this.state.width}
height={height}
ref={ref => {
this.stageRef = ref;
}}
onClick={this.handleClick}
>
<Provider store={this.props.store}>
<Layer scaleX={scale} scaleY={scale} y={20} x={20}>
<Section
section={root.sections[0]}
x={root.frameSize}
y={root.frameSize}
/>
<Sash
width={root.width}
height={root.height}
size={root.frameSize}
/>
<Metrics />
</Layer>
</Provider>
</Stage>