Replies: 5 comments 29 replies
-
|
Nobody has managed to do it because it's impossible. For hooks to work you have to use them throughout the whole lifetime of your component, unconditionally. From what I understand |
Beta Was this translation helpful? Give feedback.
-
|
Hey @xvrdm I created this codesandox as an illustration of how to use xstage + react-query. I think it might help: https://codesandbox.io/s/xstate-react-query-emeyl Any suggestion is welcome! |
Beta Was this translation helpful? Give feedback.
-
|
Hi, react-query maintainer here. I know little about xstate, so bear with me please 😅 . While Am I wrong in seeing xstate being a very good match for complex client state, where If I want to trigger a fetch when a certain state is reached, why not use the |
Beta Was this translation helpful? Give feedback.
-
|
Did this get any further? It would be great to have a non-hook API from react-query that could be alongside xstate. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks anyway for sharing. It’s still a very interesting approach.
…On Fri, Oct 14, 2022 at 23:44, Denis Borovikov ***@***.***> wrote:
I've found this approach doesn't work if you need to pass query parameters from the machine's context/event to useQuery. refetch allows you to refetch the existing query but there's no way to modify it for now.
—
Reply to this email directly, [view it on GitHub](#1813 (reply in thread)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAXXBTN7KHH6AKWMNODSNBLWDHH2LANCNFSM4VU24IVQ).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Has anybody managed to use a react hook inside the 'invoke' part of a machine?
I have a machine that uses
fetchin thesrcof one of itsinvokeparts. It works well.I am now trying to change this code to use
useQueryfromreact-query. This yields an error that seems to indicate that hooks cannot be used in a machine (or any other non-react component).The react code:
the machine code:
Thanks for the awesome work on xstate (and the FEM courses): first time I find state machines approachable!
Beta Was this translation helpful? Give feedback.
All reactions