Reputation: 1227
I'm using reac-admin, and want that after edit to redirect the user to custom route.
<Edit {...props}>
<TabbedForm redirect={redirect(`/XXX/${props.id}/YYY`)} >
{/* fileds */}
</TabbedForm >
</Edit>
in the custom routes I have this route:
<Route exact path="/XXX/:id/YYY" render={(props) => <MyRoute {...props} />} />
My problem is how to pass props like in show?
why when redirect to show : redirect="show"
, the props which are passed are different than when redirect to a custom route?
There are missed props which I need them like the id.
What sholud I do to solve my problem?
Thank you!
Upvotes: 1
Views: 707
Reputation: 7066
You have two ways to do that:
<Route exact path="/XXX/:id/YYY" render={() => <MyRoute />} />
And inside MyRoute:
import { useParams } from 'react-router';
const MyRoute = () => {
let { id } = useParams();
// ...
}
<Route exact path="/XXX/:id/YYY" render={(props) => <MyRoute id={props.match.params.id} />} />
Upvotes: 6