Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【快应用】mobx使用在apptsx #4248

Closed
M075097 opened this issue Aug 21, 2019 · 6 comments
Closed

【快应用】mobx使用在apptsx #4248

M075097 opened this issue Aug 21, 2019 · 6 comments
Assignees

Comments

@M075097
Copy link

M075097 commented Aug 21, 2019

问题描述
[问题描述:mobx使用,在app.tsx中的入口处使用Provider,在具体组件中inject时报错:MobX injector: Store 'XXX' is not available! Make sure it is provided by some Provider]

//app.tsx
 render() {
    return (
      <Provider store={store}>
        <Index/>
      </Provider>
    );

期望行为
[可以正常使用mobx]

报错信息
pages/index/index.js:14579: Error: MobX injector: Store 'store' is not available! Make sure it is provided by some Provider
Error: MobX injector: Store 'store' is not available! Make sure it is provided by some Provider
at pages/index/index.js:14577:21
at Array.forEach ()
at pages/index/index.js:14575:16
at Object.mapStoreToProps (pages/index/index.js:14603:34)
at new Injector (pages/index/index.js:13980:169)
at Object.createComponent (pages/index/index.js:17283:27)
at scriptModule (pages/index/index.js:6477:191)
at pages/index/index.js:42021:6
at nr (:1:108995)
at s (:1:110893)
com.eclipsesource.v8.V8ScriptExecutionException
at com.eclipsesource.v8.V8._executeVoidFunction(Native Method)
at com.eclipsesource.v8.V8.executeVoidFunction(SourceFile:1133)
at com.eclipsesource.v8.V8Object.executeVoidFunction(SourceFile:435)
at org.hapjs.render.jsruntime.JsThread.b(SourceFile:664)
at org.hapjs.render.jsruntime.JsThread.a(SourceFile:69)
at org.hapjs.render.jsruntime.JsThread$a.handleMessage(SourceFile:240)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。

  • Taro 版本 [1.3.13]

补充信息
1.可以确定的是在app.tsx中声明的Provider,最终会调用@tarojs/mobx/index.js 中的setStore,此调用是正常且store值是set成功的,但是实际在Index页面中调用inject时,此处再次import :@tarojs/mobx/index.js 时里面的store实际值为{},导致最终不匹配报错,这个问题不知道是不是快应用JS引擎的原因

@taro-bot
Copy link

taro-bot bot commented Aug 21, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@nanjingboy
Copy link
Member

@M075097 信息太少了

@taro-bot
Copy link

taro-bot bot commented Aug 23, 2019

Hello~

您的问题所提供的信息不足,我们无法定位到具体的问题。如果有空的话还请拔冗提供更具体的信息,否则这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@Num142857
Copy link

我也碰到了同样的问题

@taro-bot
Copy link

taro-bot bot commented May 10, 2020

Hello~

您的问题所提供的信息不足,我们无法定位到具体的问题。如果有空的话还请拔冗提供更具体的信息,否则这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@nanjingboy
Copy link
Member

@Fantasy9527 1.x 更新到 1.3.43,2.x 更新到 2.2.5 就可以了。

jiangzm pushed a commit to jiangzm/taro that referenced this issue Dec 7, 2020
* fix(mobx): 修复快应用下 store 未定义的问题

* fix(mobx): 修复快应用下属性更新后页面不刷新的问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants