How to use the react-static.useBasepath 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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

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 => (
      
        {children}
      
    )

    const renderedChildren = (
      // Place a top-level router inside the root
      // This will give proper context to Link and other reach components
      
        
      
    )
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 (