#createActorContext useSelector state is typed as never

1 messages · Page 1 of 1 (latest)

tropic bolt
#

I've been using createActorContext and it is really brilliant overall. It simplifies a lot of the context boilerplate and works really well.

Unfortunately, I have been having some issues with the types from the useSelector hook returned from the context. For some reason, the state is defined as never when using it as follows

const count = SomeMachineContext.useSelector((state) => state.context.count);

Adding the type explicitly to the state seems to resolve the issue, but this should be inferring I believe. It's a little annoying having to manually type this everywhere we are using useSelector.

const count = SomeMachineContext.useSelector((state: StateFrom<typeof machine>) => state.context.count);

I can't share the actual code as it is a private repro, but in a very minimal example it seems like the inference is working.

I'm not sure what could be breaking the inference, but has anyone also experienced this issue?

lyric cedar
#

I haven't, but if you can try to make a reproduction, that would really help

tight minnow
#

I have the same problem. It's all company repo that I can't share. I'll also look if I can get a small example set up.

tight minnow