any #react experts in here? I am working on a small demo using react context and web serial api. I share some kind of service via context (connect, disconnect, etc.) and I would like to make sure I disconnect when this context provider gets unmounted.

Is that even possible to run an async call (web serial disconnect) in the provider's useEffect cleanup call?

@florin Yeah in react 17+, useEffect cleanup functions are run async after unmount and after the commit phase, before other effects are run. AFAIK.

I modified an example from the beta react docs. It shows that async calls within the useEffect cleanup run. https://codesandbox.io/s/spring-sky-ds7652?file=/App.js

spring-sky-ds7652 - CodeSandbox

spring-sky-ds7652 using react, react-dom, react-scripts

CodeSandbox