Skip to content

Commit

Permalink
respect path changes in Component shouldComponentUpdate method (gca…
Browse files Browse the repository at this point in the history
  • Loading branch information
gbiryukov committed Jun 14, 2017
1 parent c3938f9 commit b656439
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ export class Component extends React.Component {
}

shouldComponentUpdate(nextProps, nextState) {
const { props, state } = this
const nextPath = Boolean(nextProps.ctx) && nextProps.ctx.path
const curPath = Boolean(props.ctx) && props.ctx.path

const should = (
nextState.value !== this.state.value ||
nextState.hasError !== this.state.hasError ||
nextProps.options !== this.props.options ||
nextProps.type !== this.props.type
nextState.value !== state.value ||
nextState.hasError !== state.hasError ||
nextProps.options !== props.options ||
nextProps.type !== props.type ||
nextPath !== curPath
)
// console.log(nextState.value !== this.state.value,
// nextState.hasError !== this.state.hasError,
// nextProps.options !== this.props.options,
// nextProps.type !== this.props.type,
// should)

return should
}

Expand Down

0 comments on commit b656439

Please sign in to comment.