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
Getting the state by using the recoil state useRecoilValue(statusAtom)
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.
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.