zqc-app-demo icon indicating copy to clipboard operation
zqc-app-demo copied to clipboard

修正了release版因state.store为undefined而闪退的问题

Open xiangdong9013 opened this issue 7 years ago • 1 comments

由于首次启动时,state.store为undefined,所以更无法获取到state.store.version,所以造成生成的apk release版无法启动,直接闪退。

xiangdong9013 avatar Nov 02 '17 09:11 xiangdong9013

不会存在state.store为undefined的情况。首次启动state为undefined,会设一个默认值{store: {version: undefined}}。只要state不为undefined,那么其下的store属性要么是reducer里的默认值,要么是更新后的值,但不会是undefined。

src/setup.js

...
    let {store: {version}} = state || {store: {version: undefined}}
    if (version === undefined || compareVersions(version, VERSION) < 0) {
      store.dispatch(actions.reset())
      store.dispatch(actions.setStoreVersion(VERSION))
    }
    store.dispatch(actions.resetScreenLastRefreshTime())
    logger.info('check store version ok')
...

src/reducers/store.js

...
const initialState = {
  version: undefined
}
...

jaggerwang avatar Nov 02 '17 10:11 jaggerwang