Skip to content

using ink with valtio #535

Answered by airjp73
chrisdrackett asked this question in Q&A
Sep 14, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

I've run into the same issue, but using xstate instead.

I think the issue is actually in the use-sync-external-store shim used by both xstate and valtio. That shim has a server and client version, and since ink is running outside the browser, it uses the server version. That just returns the initial state.

Hopefully this will be fixed when ink adds React 18 support?

There are a couple workarounds I've found:

  1. Subscribe directly to the external store. I haven't used valtio personally, but I'm sure theres a similar API you can use.
const { rerender } = render(<ComponentWithXstate />);
xstateService.onTransition(() => rerender(<ComponentWithXstate />);
  1. Shim window.document.createElement.
/…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vadimdemedes
Comment options

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