【问题标题】:Redux-saga with Internet Explorer带有 Internet Explorer 的 Redux-saga
【发布时间】:2016-10-26 22:19:55
【问题描述】:

我有一个在 IE 11 中使用 redux-saga 的 React 应用

似乎出现以下错误

请注意,该应用在过去 3 年的版本的 Chrome 和 Safari 中运行良好(除了一些显示问题)

sagas.js

// functions are called bottom to top, this one is called at the end (also can be seen in stack trace below)

function* getGlobalData() {
    console.log('Get global data called');      // this is executed

    // something is failing from here on

    const [
      wardrobeResponse,
      lastListingsResponse,
    ]  = yield [
      call(api_request, {url: 'store/wardrobes/'}),
      call(api_request, {url: 'store/last_listings/'}),
    ]


    yield put(actions.wardrobe.success(wardrobeResponse.json));
    yield put(actions.lastListings.success(lastListingsResponse.json));



}

/**
 * Watches for LOAD_SEARCH_RESULTS action and calls handler
 */
function* getGlobalDataWatcher() {

    console.log('Get data - check if working');
    console.log("global data watcher saga run")
    yield take(Constants.LOAD_GLOBAL_DATA)
    console.log('LOAD_GLOBAL_DATA received in saga')
    const state = yield select()

      if (state.getIn(['global', 'wardrobes']).isEmpty()) {
          console.log('Empty global data, call api')
          yield call(getGlobalData);
      } else {
          console.log('Global data already present, dont call API')
      }

}




function* data() {
  console.log('Get global results saga data called');
  yield fork(getGlobalDataWatcher);
}


export default [
  data
]

控制台错误

uncaught at data 
 at loadMeDataWatcher 
 at loadMeData 
 TypeError: Object doesn't support this action
   at api_request (http://localhost:3002/main.js:5905:3)
   at runCallEffect (eval code:446:7)
   at runEffect (eval code:370:5)
   at next (eval code:259:9)
   at currCb (eval code:329:7)
   at runSelectEffect (eval code:651:7)
   at runEffect (eval code:370:5)
   at next (eval code:259:9)
   at proc (eval code:214:3)
   at resolveIterator (eval code:390:5)

【问题讨论】:

    标签: reactjs redux react-redux redux-saga react-boilerplate


    【解决方案1】:

    您可以将“babel-polyfill”安装到您的依赖项中,并将这一行添加到您的 app.js。

    import 'babel-polyfill'; 
    

    See more

    【讨论】:

    • 您可能想尝试更小的导入来达到同样的效果:import 'core-js/es6/symbol。对我来说,这只增加了 11KB 的包大小,而 babel-polyfill 增加了 87KB 的包大小。此外,core-js 已经是 npmjs.com/package/create-react-app 的一部分。唯一需要注意的是:我使用针对 ES5 的 TypeScript 和 downlevelIterationoption 成功地尝试了这个。所以可能是上面的导入对于 JavaScript 来说是不够的。如需更深入的讨论,请参阅我的(已接受)PR 到“create-react-app-typescript”:github.com/wmonk/create-react-app-typescript/pull/194
    猜你喜欢
    • 2021-04-22
    • 1970-01-01
    • 2017-10-15
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 2011-05-04
    相关资源
    最近更新 更多