How to use the react-static.useStaticInfo function in react-static

To help you get started, we’ve selected a few react-static examples, based on popular ways it is used in public projects.

github react-static / react-static / packages / react-static-plugin-reach-router / src / browser.api.js View on Github external
Root: PreviousRoot => ({ children, ...rest }) => {
    const basepath = useBasepath()
    const staticInfo = useStaticInfo()

    const RouteHandler = props => (
      <PreviousRoot {...rest} {...props}>
        {children}
      </PreviousRoot>
    )

    const renderedChildren = (
      // Place a top-level router inside the root
      // This will give proper context to Link and other reach components
      <Router {...(basepath ? { basepath } : {})} {...userRouterProps}>
        <RouteHandler path="/*" />
      </Router>
    )

    // If we're in SSR, use a manual server location
github react-static / react-static / packages / react-static-plugin-react-router / src / browser.api.js View on Github external
Root: PreviousRoot => ({ children }) => {
    let Router
    const basepath = useBasepath()
    const staticInfo = useStaticInfo()

    const routerProps = {
      basepath, // Required
    }

    // Test for document to detect the node stage
    if (typeof document !== 'undefined') {
      // If in the browser, just use the browser router
      Router = BrowserRouter
    } else {
      Router = StaticRouter
      routerProps.location = staticInfo.path // Required
      routerProps.context = {} // Required
    }
    return (
      <PreviousRoot>