Make hasPathChanged on the Guard component configurable #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The parent route will rerender (destroy and initialize) each time the user navigates between child routes.
This can cause issues when fetching data inside a container/parent component or when the parent component must hold some state because the component will lose his current state each time the user navigates between the child routes.
Therefore I thought it will be a good idea to make the
hasPathChanged
function configurable so the developer can choose when the guards of the parent should be called.Example:
Navigate to /users => check user guards
Navigate from /users to /users/123 => don't check the /user guards (don't destroy the /users route)
Navigate from /users/123 to /users/overview => don't check the /user guards (don't destroy the /users route)
What this does
It will allow the developer to set his own
hasPathChanged
function.