RyanRoll / react-use-api

Async HTTP request data for axios. Designed for diverse UI states, SSR and data pre-caching.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to append script with clientCacheVar to head element

vinks opened this issue · comments

If we process injectSSRHtml with <html>content</html>, then the script with cache data will be appended outside DOM. Its better has option, for appending it to head of page.

commented

It makes sense, I'll do an enhancement these days.

commented

This requirement has been supported.
https://github.com/RyanRoll/react-use-api#arguments-of-injectssrhtml

injectSSRHtml(
  context: ReactUseApi.CustomContext,
  renderSSR?: () => string,
  postProcess?: (ssrHtml: string, apiCacheScript: string) => string,
): string

We are able to customize the html returned from injectSSRHtml by postProcess.
By default, injectSSRHtml returns ssrHtml + apiCacheScript.