oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.06k stars 50 forks source link

The issue of passing useState values in the _layout.tsx file #112

Closed tomatoword closed 1 year ago

tomatoword commented 1 year ago

Hello. I would like to ask. I used generouted file routing, and then in my _ layout. tsx file, I used React. useState() to store data. And then I created a new folder called newNode in the same level directory as the layout.tsx file, and then created the file index.tsx in the new folder. May I obtain the data values stored in _layout. tsx from index. tsx. thanks

oedotme commented 1 year ago

Hey @tomatoword, you can use useOutletContext to pass state and other values from the _layout.tsx to its children.

I've discovered this hook from #106. Hope that helps!

tomatoword commented 1 year ago

thanks