Skip to content

Commit

Permalink
fix: 修改routerChange判断条件
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed Apr 1, 2020
1 parent c2ff736 commit 1f89653
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/ykfe-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ykfe-utils",
"version": "3.6.1",
"version": "3.6.2",
"description": "utils for ykfe",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/ykfe-utils/src/components/getinitialProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function GetInitialProps (WrappedComponent: FC): React.ComponentClass {
if (!routerChanged) {
// csr渲染模式下无论是首次打开页面还是路由跳转都需要客户端需要调用getInitialProps
// 进行过history push或者reaplace操作之后,每次进行单页跳转客户端都需要调用getInitialProps
routerChanged = !window.__USE_SSR__ || props.history && /push|replace/i.test(props.history.action)
routerChanged = !window.__USE_SSR__ || props.history && props.history.action !== 'POP'
}
}

Expand All @@ -41,7 +41,7 @@ function GetInitialProps (WrappedComponent: FC): React.ComponentClass {

render () {
// 只有在首次进入页面需要将window.__INITIAL_DATA__作为props,路由切换时不需要
return <WrappedComponent {...Object.assign({}, this.props, getProps ? {} : window.__INITIAL_DATA__, this.state.extraProps)} />
return <WrappedComponent {...Object.assign({}, this.props, routerChanged ? {} : window.__INITIAL_DATA__, this.state.extraProps)} />
}
}
return withRouter(GetInitialPropsClass)
Expand Down

0 comments on commit 1f89653

Please sign in to comment.