Hi
I am not sure about the first code because I don’t do react.
The second part seems pretty clean to setup the database. Important that the create stuff happens before anything else.
And most actions are async in that part, so you need to be sure you are waiting for them to complete before doing something else on the database. The way you defined set, might give you headaches?
I’d try a simple app or isolated page to make it work to your liking.