-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't catch thrown 'FLOW_CANCELED' anywhere #2790
Comments
useEffect(() => {
const fetch = flowResult(store.flowAction());
// ---
fetch.catch(error => console.log("CATCHED"));
// ---
return () => fetch.cancel();
}, [store]); |
I think we should add usage(code example) to official document. urugtor's code snippt is a great solution. |
Oops! It's my mistake not to try that way. Thank you @urugator I thought it should be handled inside the flow method! I tried it on the actual product and it worked perfectly as I wanted. @iChenLei Thank you for your time everyone! |
@DMS40 please keep it until we get a unanimous view for |
@iChenLei yeah it is probably good to mention that the promise returned from the flow will reject and can be catched. You can't catch it inside the flow itself, but as mentioned the finalization block will run so could be used to detect it. |
Intended outcome:
This issue came from here
When flow function's
cancel()
fired, Can't catch thrown 'FLOW_CANCELED' anywhereActual outcome:
Can catch the flow function's
cancel()
fired, for don't want to show throw error messageThis also interferes with the integrated test. like for react-testing-library
How to reproduce the issue:
https://codesandbox.io/s/magical-hugle-qc0d1?file=/src/App.js
Versions
mobx : 6.1.5
mobx-react-lite : 3.2.0
react : 17.0.1
react-dom : 17.0.1
react-scripts : 4.0.0
The text was updated successfully, but these errors were encountered: