brillout / react-streaming

React Streaming. Full-fledged & Easy.
MIT License
216 stars 14 forks source link

Question about useAsync #24

Closed tbrannam closed 1 year ago

tbrannam commented 1 year ago

I am building node and browser target modules in my project.

I was wondering if there were commonly used techniques that may allow me to strip the factory function from useAsync to essentially allow to be only ever run on the server, and to mask the existence of the upstream server (used in the fetch).

// node
const data = useAsync('key', () => fetch('http://foobar/resource').then(res => res.json());
// web
const data = useAsync('key', /* empty or empty function that never gets called */);

This is likely going to have to be bundler specific.

brillout commented 1 year ago

I'd say it's out-of-scope for this project.

Feel free to fork it though, it isn't much code anyways.