0

I have common details view in my react app. Right now my detail view URL is like that

blog-details/:blogId

But I want to change the URL like this

host.com/{blog-title}/{blog-type}/{blog-id}

how can I do it? I'm using react-router and I want to use single details to view component with a different dynamic URL slug.

3
  • Provide an updated path="/:blogTitle/:blogType/:blogId" prop, something like this? Please include a Minimal, Complete, and Reproducible code example of your attempt. Commented Dec 7, 2020 at 9:08
  • @DrewReese it's going to be work cz every time the blog title and other things are different? Commented Dec 7, 2020 at 9:10
  • Work to change your code to handle the routes/paths you want it to? Your question is unclear. Commented Dec 7, 2020 at 9:24

1 Answer 1

2

u can specify some route to a component like this :

 <Route
    exact
    path={[
      "/:title",
      "/:title/:type",
      "/:title/:type/:id",
    ]}
    component={Blog}
  />
Sign up to request clarification or add additional context in comments.

4 Comments

how did you get that? do you have any docs?
How can we do that in react router v6 ? it doesnt accept array in Path property
You should make another question i think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.