question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

basePath not working on top level component

See original GitHub issue

Hello,

First - thanks for this nice library. I have s one struggle. In hookrouter you can use setPath function on start application (https://github.com/Paratron/hookrouter/blob/master/src-docs/pages/en/05_serverside-rendering.md#setting-the-path)

I have react application which is serving in subofolder - for example (www.sampleapp.com/subfolder/sampleapp.

In top level component i have define routes:

const route = useRoutes(AppRoutes, { basePath: "sampleapp" });

But this is not working.

Is there any workaround, how i use basePath(setPath) for this usecase?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
martinsuracommented, Sep 1, 2020

Nice, this is exactly my use case and it works!

Thanks for the help.

0reactions
kyeoticcommented, Sep 1, 2020

This is because the <Link>s in the app render are outside of the useRoutes result, so they can’t inherit the basePath from it. The basePath is only provided to components rendered by useRoutes. Does that make sense?

You can provide the basePath to the <Link>, or you can create a wrapped version of the <Link> that has its own basePath defined.

const AppLink = (props) => <Link {...props} basePath='test' />

Check out this example

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Blazor WASM base path problems - elmah.io Blog
This post will show you how to fix a common problem when setting the application base path with Blazor WebAssembly.
Read more >
Better `basePath` support · Issue #914 · loopbackio/loopback ...
Currently, you can set a spec.basePath at the top-level of your spec, but it does not cascade down as expected to all the...
Read more >
Next.js basePath not working for assets : r/reactjs - Reddit
I'm working on a little internal utility app for my self at work that doubles as a proof-of-concept for Next.js for use in...
Read more >
How to change basepath on deployment of Vue app
This has recently been a problem for me. And the above solutions did not work. The below solution works for vue 2.6 ,...
Read more >
Deploy your NextJS Application on a different base path (i.e. ...
Build a Multi-Container Docker Application with Docker Compose with a React, Node, and Postgres App.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found