I want to create (SQLite-)Tables and load some stored data from them, to show them in different tabs. What’s the best practice to do this?
I’m creating the tables if they don’t exists, load data from some tables and set a state variable “initialized” to true, so that useEffect is running on it’s change. Like @aaronksaunders describes here.
I see two problems:
- I’m trying to create the tables unnecessary often.
- Some tabs don’t update the data after I set the variable to initialized, although I do the table-functions in a component imported by all tabs and set all useEffects to listen to change of “initialized”. If I rerun useEffect by hand it works.
Is it good to store a value in a table, for example “created” and set it to “true” after I created the tables at the first run of the app?
How can I do it that the tabs are updated or other function are waiting for my table-stuff?