Dva: Cannot read property 'asyncComponentsAncestor' of undefined

Created on 27 Sep 2017  ·  9Comments  ·  Source: dvajs/dva

  • 环境:dva@2
  • 触发条件:升级到 React 16.0.0

报错:

Warning: Failed child context type: Cannot read property 'asyncComponentsAncestor' of undefined
    in AsyncComponent (created by Route)
    in section (created by CoreLayout)
    in CoreLayout (created by Route)
    in Route
    in Switch
    in Router
    in Provider
    in Unknown
bug

Most helpful comment

考虑把 react-async-component 给换了,用 https://github.com/faceyspacey/react-universal-component 或者自己实现吧。

All 9 comments

考虑把 react-async-component 给换了,用 https://github.com/faceyspacey/react-universal-component 或者自己实现吧。

试着升级 example 的 react 到 16,发现这个问题应该和升级 react@16 无关。https://github.com/dvajs/dva/commit/953966332558cdacfc106ee7360a74727b8e5f3e

@sorrycc dva-example 路由没有异步加载,所以不会出现该错误。而 dva-example-user-dashboard 路由使用了异步加载,升级到 react 16,则会出现该错误。

使用到dynamic就会出现这个问题

使用了()=>还是会报错,不知道为什么

v2.0.3 does not include this fix. I'm waiting for this to be release on NPM. Thanks.

+1

Was this page helpful?
0 / 5 - 0 ratings