#Is Jotai a good alternative to @xstate/react provider?

1 messages · Page 1 of 1 (latest)

lavish ocean
#

I'm used to jotai and i find providers too confusing. Id like to just put my macine in the atom and reuse it to get and set in any of my components. However im not sure if thats going to gift me unexpected nightmares. May I pretty please have some clarification? 🥺

https://jotai.org/docs/extensions/xstate im not even sure it is compatible with v5, but their last page update on github was only 4 months ago so i assume it is.

safe monolith
#

I don't use React provider and use actors created outside of React (started and exported from a module).
It should be the same, a module is only imported once and cached.
This is ok if you only want a "singleton" actor.
Provider seems ideal if you need to customise a "singleton" actor based on some changes after its creation, easy to re create an actor and save it in a React context

tranquil wigeon
#

Jotai doesn't support XState v5 yet

#

You can just create a "module-scope" actor and pass it around

lavish ocean
lavish ocean
#

What i like about createActorContext is that you can provide state. It's like a hydration of your actors on the bootup? Would it be possible to do without Provider and createActorContext

safe monolith