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

[Bug]: Using embed in a route with param causes it to render the whole application inside the div. #11500

Closed
sakmalh opened this issue Apr 25, 2024 · 1 comment
Labels

Comments

@sakmalh
Copy link

sakmalh commented Apr 25, 2024

What version of React Router are you using?

6.23.0

Steps to Reproduce

import { BrowserRouter, Routes, Route } from "react-router-dom";
import Layout from "./pages/Layout.jsx";
import Home from "./pages/Home.jsx";
import Blogs from "./pages/Blogs.jsx";


export default function App() {
    return (
        <BrowserRouter>
            <Routes>
                <Route path="/" element={<Layout />}>
                    <Route index element={<Home />} />
                    <Route path="blogs/:id?" element={<Blogs />} />
                </Route>
            </Routes>
        </BrowserRouter>
    );
}
const Blogs = () => {
    return (
        <div>
            <embed src="dummy.pdf" type="application/pdf"/>
        </div>
    )
};

export default Blogs;

when the url is example.com/blogs there isnt any issue and it renders correctly. But when there is an id in the blogs it renders the whole app inside where the pdf is supposed to display. Tried iframe and object along with embed. Tried using Switch also. refresh on the url with the id if the problem does not show.

Expected Behavior

Supposed to show the pdf even if the id in url exists

Screenshot from 2024-04-25 20-46-03

Actual Behavior

Renders a dupplicate of the whole app inside the embed

Screenshot from 2024-04-25 20-46-30

HTML Snippet. Loops repeatedly
image

@sakmalh sakmalh added the bug label Apr 25, 2024
@timdorr
Copy link
Member

timdorr commented Apr 26, 2024

It looks like your application server isn't set up to serve static files and is instead serving up your React app. This isn't a bug with React Router.

@timdorr timdorr closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants