kpaxqin / redux-action-tools

Light-weight action tools with async and optimistic update support.
107 stars 11 forks source link

Redux Possible Unhandled Promise Rejection #4

Open StarHosea opened 7 years ago

StarHosea commented 7 years ago

您好,刚接触Redux,React Native。 使用您的库如果异步Action发生错误,RN会warning : Possible Unhandled Promise Rejection。 发现 createAsyncAction 中,下面一行代码注释掉就没有warning了。

function createAsyncAction(type, payloadCreator, metaCreator) {
      .....
      return promise.then(value => {

      }, e => {
        dispatch(
          failedAction(e, getAsyncMeta(metaCreator, e, ASYNC_PHASES.FAILED))
        );
        return Promise.reject(e);//这里为什么还要返回错误呢
      });

}
kpaxqin commented 7 years ago

可以参考这两个issue的回答:

https://github.com/kpaxqin/redux-action-tools/issues/3 https://github.com/kpaxqin/redux-action-tools/issues/2

看来不少人有这个疑惑,我稍后考虑补全文档和示例