Hi,
I am currently testing redwood and checking out its structure. I have an existing project, where I try to fetch data via hooks, which allows me to separate the data fetching from my client app.
// simple example
const useProject = (id) => useReactQuery(....) or useFirebase or whatever
const MyComp = ()=>{
const project = useProject(1)
return <div>{project}</div>
}
Now in redwood it seems, I would need to place Cells within my existing client app at those places, where I need data.
That made me think about rather using hooks instead of Cells in redwood. Redwood could become kind of “headless”, since it would only handle routing, maybe a bit of layouting, but data fetching (probably all crud operations) would be done through hooks. React-Query could probably do this easily with its caching mechanims or is this actually already possible via apollo and just needs proper generators?
If I want to seperate concerns in my client app, I could also wrap a cell within my own component the way I would do it with hooks, but it is actually much more inconvenient.
// simple example - pseudo code
const GetProject = () => <ProjectCell ....>
<ContectProvider value={projectData}>
{children}
<ContextProvider />
</ProjectCell>
const MyCompWithinGetProject = ()=>{
const project = useProjectContext(1)
return <div>{project}</div
}
The hook approach allows me to do the query within a component, the cell approach requires me to do it within a parent component.
Are there existing patterns to use hooks for fetching instead of cells?