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

Allow useRedirect to set location state #6275

Closed
WiXSL opened this issue May 12, 2021 · 4 comments · Fixed by #6293
Closed

Allow useRedirect to set location state #6275

WiXSL opened this issue May 12, 2021 · 4 comments · Fixed by #6293

Comments

@WiXSL
Copy link
Contributor

WiXSL commented May 12, 2021

Currently, the location state is hard-coded (state)
and not accessible from outside.

It would be nice to be able to pass state to the location, something like

const redirect = useRedirect();
const someState = { fromState: true};
redirect('edit', '/posts', 123, {}, someState);
despatates added a commit to despatates/react-admin that referenced this issue May 20, 2021
despatates added a commit to despatates/react-admin that referenced this issue May 20, 2021
@fzaninotto
Copy link
Member

What's the use case for that?

@despatates
Copy link
Contributor

I have a use case where I must prefill a <Create /> form with some values (doc), and those values are depending on the result of a request to the server.
I can't ask my user to click on a button to redirect him, I want to do this automatically with a redirect().

@Bossieh
Copy link

Bossieh commented May 31, 2021

What's the use case for that?

In same cases my resource edit page is accessible from different locations, so I would to return the user to the page where he came from.

So in my case I would to store the "fromUrl" in the state.

@fzaninotto
Copy link
Member

Fixed by #6293

ogustavo-pereira pushed a commit to ogustavo-pereira/react-admin that referenced this issue Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants