As a general rule of thumb separate "getter" hooks from "setter" hooks. E.g. use one hook to set the state and another to fetch that state.
Setting the state from the useCheckForUpdates
hook
29k/client/src/lib/codePush/hooks/useCheckForUpdate.ts
Lines 50 to 62 in 5dc9ce4
Getting the state by using the zustand state useCodePushState(state => state.status)
29k/client/src/lib/codePush/components/CodePushOverlay.tsx
Lines 50 to 58 in 952b16c
We use react-native-firbease/firestore in our project, as a general rule though, we decided to only use it in cases where we need live-updates.
You can read more about how firestore snapshots work, that's what we use for live data UX.
For the rest of database query operations we use our REST API, which can aggregate and take further responsibility for how we provide data to our client.
A decent example of such usage can be found on our useTemple
react hook.
29k/client/src/routes/Temple/hooks/useTemple.ts
Lines 7 to 31 in 237ee21
A wrapping API layer enabling a centralized way of accessing and modifying data. As most REST API we use the method from the request to indicate which operation to perform:
GET /fruit // Provides all the fruits Fruit[]
GET /fruit/:id // Provides a fruit based on the ID used Fruit
POST /fruit // Creates a new fruit
PUT /fruit/:id // Updates an exisitng fruit
DELETE /fruit/:id // Deletes an exisitng fruit
An example is the Temple endpoint.