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

Fix useRedirect does not handle query strings #6145

Merged
merged 2 commits into from Apr 10, 2021

Conversation

fzaninotto
Copy link
Member

Problem

PR #5905 broke useRedirect when using a query string:

const redirect = useRedirect();
// ...
redirect('/foo?bar=baz');

Because of the following change:

-           history.push(resolveRedirectTo(redirectTo, basePath, id, data));
+           history.push({
+               pathname: resolveRedirectTo(redirectTo, basePath, id, data),
+               state: { _scrollToTop: true },
+           });

Solution

Transform the redirection target to a react-router location object.

Closes #6141
Supersedes #6009

@fzaninotto fzaninotto added the RFR Ready For Review label Apr 9, 2021
Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

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

There are linter warnings though

@djhi djhi merged commit e0fb207 into master Apr 10, 2021
@djhi djhi deleted the Fix-redirect-to-query-string branch April 10, 2021 20:28
@fzaninotto fzaninotto added this to the 3.14.3 milestone Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirecting to create page with useRedirect try to load the edit page
2 participants