Skip to content

Service not initialised when passed to React.Context #1256

Answered by davidkpiano
duerdod asked this question in General
Discussion options

You must be logged in to vote

A quick workaround is to add a conditional existence check before rendering.

This will probably be solved in the upcoming @xstate/react v1.0, as the service is started immediately, or at least will have its state available immediately. It's a bit tricky to determine what to do here, since React has no notion of "initial effects", as the initial render is supposed to be without any effects, and service.start() is technically an effect.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@duerdod
Comment options

@Andarist
Comment options

Answer selected by duerdod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants