hookrouter
hookrouter copied to clipboard
useRoutes doesn't get base route in browser after (local network) deploy
Using the basic example in the README, it looks like the useRoutes method identifies the root (or perhaps the first) route of the identified routes, and sets that as the first/default route. I deployed this to a local server and am trying to access it via Chrome. Unfortunately none of the routed content appears in the DOM.
example
const routes = {
'/': () => <Root methods={{ navigate }} />,
'/id': () => <Id state={state} methods={{ handlePropIdUpdate, navigate }} />,
'/contact': () => <Contact state={state} methods={{handleNotificationMethodUpdate, navigate}} />,
'/contact/email': () => <Email state={state} methods={{handleEmailAddressUpdate, navigate}} />,
'/contact/phone': () => <Phone state={state} methods={{handlePhoneNumberUpdate, navigate}} />,
'/thankyou': () => <ThankYou methods={{submitDataToApi, navigate}} />,
}
const currentRoute = useRoutes(routes)
return (
<Layout>
{currentRoute || <Root methods={{navigate}} />}
</Layout>
)
If, however, I replace the currentRoute call with {currentRoute || <Root methods={{navigate}} />}, it works. If this is a known issue, mind if I update your docs to (more explicitely) reflect that?