Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Drop componentWillReceiveProps #308

Merged
merged 2 commits into from
Apr 5, 2019
Merged

refactor: Drop componentWillReceiveProps #308

merged 2 commits into from
Apr 5, 2019

Conversation

taion
Copy link
Contributor

@taion taion commented Mar 29, 2019

Closes #171

@taion

This comment has been minimized.

@@ -84,19 +93,26 @@ export default function createBaseRouter({
}
}

componentWillReceiveProps(nextProps) {
static getDerivedStateFromProps({ match, resolver, matchContext }, state) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't run on the initial render

resolver,
matchContext,
iteration: state.iteration + 1,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use getSnapshotBeforeUpdate() and cheat a bit since it is an instance method: return this.shouldResolveMatch = true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need to update stuff before render, though, so this.lastIteration === iteration evaluates as false in render and prevents the unnecessary update

@taion taion changed the base branch from context to master April 5, 2019 14:28
@taion taion merged commit d9c52b4 into master Apr 5, 2019
@taion taion deleted the wip branch April 5, 2019 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants