react-fetching-library icon indicating copy to clipboard operation
react-fetching-library copied to clipboard

expose promises for server side rendering

Open tmjam opened this issue 5 years ago • 3 comments

In order to use this library with server-side rendering techniques other than Nextjs, it needs a way to expose all the promises registered via useQuery so the server-side can await all those promises to resolve before re-rendering the application.

tmjam avatar Oct 16 '19 15:10 tmjam

Do you use any library for SSR? If so could you provide example in codesandbox? It will help me with finding a way to solve your problem 🙂

marcin-piela avatar Oct 16 '19 18:10 marcin-piela

Not using one currently, I wanted to use react-fetching-library library and add SSR support built into it. The approach would be similar to this library. https://github.com/simoneb/axios-hooks where it exposes all the promises registered that can be awaited upon.

tmjam avatar Oct 16 '19 19:10 tmjam

@tmjam Does this not work for you?

const { query } = useQuery(action, false);
// elsewhere in your component in an async function:
const response = await query()

rlaffers avatar Aug 25 '20 21:08 rlaffers