Inertia and shared data in React
Hello, I have been trying to make this work but I can't find a way.
I have encountered the following problem and need some assistance:
- I have two different pages in React, each rendered by two different endpoints in Laravel.
- Each user can have different areas, and both pages should display information related to the area selected by the user.
- When a user visits one of these pages for the first time, there should be a form to select the desired area to work with.
- Once the user selects an area, I want to store that state so that if they navigate to the other page, they won't be asked again to choose an area.
How can I effectively share the area information? I want the user to select an area on one page, and then if they navigate to the other page, I can retrieve that state without asking them again.
I have come across the Inertia middleware, but I am unsure if adding the area to the session within the middleware is a viable solution. Would the form need to submit a POST request to update the session?
Any guidance or suggestions would be greatly appreciated. Thank you!
(I am using React)
Please or to participate in this conversation.