Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  13] [ 5]  / answers: 1 / hits: 42588  / 4 Years ago, sun, september 6, 2020, 12:00:00

I can't manage to pass props to my Outlet components in the new react-router v6. I tried the straightforward solution:


render() {
return (
<Outlet name="My name" />
);
}

And that correctly renders the child component, however no props are passed to the child. None of the examples provided by the React team (or anyone else for that matter) display Outlets with props, so I'm worried it's not actually a thing. Is there another way I'm not finding or am I using Output components incorrectly?


Edit: Seems there's no straightforward way to pass props, see answer below.


More From » reactjs

 Answers
69

You can do it with
outlet context


[#50665] Tuesday, August 25, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bruno

Total Points: 602
Total Questions: 100
Total Answers: 111

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;