ellers
Async Context and Store using route param
I'm sure the answer to this will be deceptively simple but I can't figure it out.
In my SolidStart project, a user navigates to a "project" by route, e.g. /project/foo.
The file is
/project[key].tsx
and using const params = useParams()
can retrieve params.key
perfectly.
The next step was:
This works great and I can then use <Suspend>
and friends and project data renders when available.
BUT as you can imagine, the loaded project data and operations on that data are needed deeply throughout the page.
To avoid prop drilling I want to make a Context
that provides a Store
to provide both the data and the operations.
At the top-level this reads fine:
That provider is drafted as below... I know it's not right but I don't know how to get the data returned by createAsync
to updated or set into the context:
I know that createAsyncStore
exists but I don't understand what it returns and how to use it in a context.
Any help most appreciated!13 replies