Last active
November 26, 2019 20:09
-
-
Save arackaf/366348066ea920a55f6f95fb2e78998d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useSuspenseQuery = options => { | |
const [resource] = useState(() => new DataQueryingThingWithState()); | |
resource.readLatest(options); //will throw a promise if not ready | |
useEffect(() => { | |
return () => resource.current.dispose(); //never call in the side rendering / "parallel universe" tree :( | |
}, []); | |
return resource.current.state; // or whatever | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i guess as the throw happens before useEffect, the callback might have not registered.