Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route specific components are not rendering in a react app #74

Open
arunkumar413 opened this issue Mar 5, 2024 · 7 comments
Open

route specific components are not rendering in a react app #74

arunkumar413 opened this issue Mar 5, 2024 · 7 comments

Comments

@arunkumar413
Copy link

For react apps the route specific components are not rendering. Seems like as the URL changes in the URL bar, the nutria system is trying to render a HTML file instead of react component. I tried the below react rotuer config but the component doesn't render.

export const AppRouter = createBrowserRouter(
  [
    {
      path: "dist/index",
      element: <Home />,
    },
    {
      path: "dist/about",
      element: <About />,
    },
    {
      path: "dist/contact",
      element: <Contact />,
    },
  ]

);
@fabricedesre
Copy link
Contributor

Nutria's http server is a static server, it doesn´t do any transformation on the content. So your react build system is responsible to produce the html content.

@arunkumar413
Copy link
Author

@fabricedesre I think it's the server that is trying to send a text/html mime type for the route instead a react component.

@fabricedesre
Copy link
Contributor

What is the content of the file? What is being displayed?

@arunkumar413
Copy link
Author

The route specific react components are of JSX

@fabricedesre
Copy link
Contributor

is your app loading properly if you use another static http server and a web browser? (eg. python -m http.server). At least the initial page needs to be proper html/js to load whatever react needs to deal with jsx if it's not turned into regular html/js at build time.

@arunkumar413
Copy link
Author

@fabricedesre the HTML file and bundle JS script file are loading fine. It's just the route specific components that are not rendering. I just raised the issue ( remix-run/react-router#11333 ) with the. react router team as well. Let's wait for their thoughts as well.

@arunkumar413
Copy link
Author

@fabricedesre I was suggested to use the right combination of start_url in webmanifest and basename property ( https://reactrouter.com/en/main/routers/create-browser-router#basename ) in react couter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants