Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6208

Stream of values with react hooks

$
0
0

I have value X coming from the server. I would like to expose an interface similar to

interface Xclient {
    getX(): Promise<X>
}

that I will later use from my react function component.

I say similar because behind the scenes I want it to:

  1. first return value from the storage (its react-native)
  2. simultaneously dispatch network call for newer version of X and re-render the component once I have the response

so instead of Promise I probably need Observable. But then how to use it with react in general and react hooks in particular?

I'm coming from the backend background so there may be some more canonical approach that I dont know about. I really dont want to use redux if possible!


Viewing all articles
Browse latest Browse all 6208

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>