-
Notifications
You must be signed in to change notification settings - Fork 142
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
fix #276 #288
fix #276 #288
Conversation
…efreshes on same route fix faceyspacey#276
@sergio-toro is that what you had in mind for the fix? |
@connorsmallman I've added a special case to update only @ScriptedAlchemy / @hedgepigdaniel do you mind taking a look? |
Will take a look today! 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic + tests looks correct to me
@@ -41,6 +41,20 @@ export default (initialState: LocationState, routesMap: RoutesMap) => ( | |||
routesMap | |||
} | |||
} | |||
else if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why this needs to be a separate if/else branch instead of adding another clause on in the condition of the first if statement line 27 such as ... || action.meta.location.kind !== state.kind)
?
If the condition is getting too complex, perhaps its worth splitting it out into a helper function, e.g. shouldRefreshState
? Not a big deal, it just seems unfortunate to introduce an extra case if it could be covered by the first one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case only needs to update the kind
variable when the pathname and search are the same.
If we do a full update it will store on state.prev
the same location, which It feels wrong because we haven't transitioned to a new route, we just need to call the thunk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hedgepigdaniel Thanks for pointing, the condition was not correct. I've updated it to the expected case (pathname and query equal but kind updated)
Update state when action has kind of 'push'
Updating the state forces the current route thunk to be called again allowing a refresh of the current route.