umijs / umi-example-ssr-with-egg

example for building frontend app with umi Server-Side Render and PreRender
80 stars 11 forks source link

在渲染组件时这个三者的调用顺序 #12

Open iisbigfish opened 5 years ago

iisbigfish commented 5 years ago

image

static getInitialProps = async ({ store, route, isServer}) => {
    console.log('new route page init props');
  }
  componentWillUnmount() {
    console.log('new route page will unmount');
  }
  componentDidMount() {
    console.log('new route page did mount');
  }

我在我代码里写这样的会出现死循环

iisbigfish commented 5 years ago

找到问题了,我在全局的layout里connect了一个dva里的页面数据。然后数据请求回来,更新dva里的数据后,layout的render重新调用,但是奇怪的是为什么会把组件卸载了,然后重新走一遍完整this.props.children里的生命周期?