Xstate: React hooks loose StateSchema types

Created on 5 May 2020  路  2Comments  路  Source: davidkpiano/xstate

Feature request description
React hooks do not allow StateSchema generic types to be passed and always pass any to StateMachine

Current Behaviour
StateSchema is always typed to any in useMachine and useService hooks, resulting in the state object coming back as not being typed.

Expected Result
A generic type to be exposed by the hooks for the StateSchema

Reproduction

bug

Most helpful comment

Thanks @davidkpiano. That's what I was looking for.

All 2 comments

Typestates don't use the StateSchema. Please see https://codesandbox.io/s/floral-shadow-8qoy3?file=/src/index.tsx

The StateSchema is only useful for constructing the machine, and that information is not needed after the machine is constructed.

Thanks @davidkpiano. That's what I was looking for.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rodinhart picture rodinhart  路  3Comments

amelon picture amelon  路  3Comments

bradwoods picture bradwoods  路  3Comments

drmikecrowe picture drmikecrowe  路  3Comments

ifokeev picture ifokeev  路  3Comments