Here is the app component:
return (
<BrowserRouter>
<div className="flex border-2 border-grey flex-col max-w-4xl min-h-screen mx-auto">
<Navigation />
<MainContainer>
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route>
<CreateBlog path="/create" />
</Route>
<Route>
<FullBlogDetails path="/blogs/:id" />
</Route>
</Switch>
</MainContainer>
</div>
</BrowserRouter>
);
}
The problem is that each time I click a blog, it redirects me to "/create", instead of "/blogs/:id".
Here is the Link that does the navigation:
<Link
to={`/blogs/${id}`}
key={id}
className="p-4 flex border-2 border-grey-200 items-center hover:shadow-lg my-6"
>
<div>
<img className="h-20" src={picture} />
<p className="">
Written by{" "}
<span className="text-rose-500 font-bold text-lg">
{firstName + " " + lastName}
</span>
</p>
</div>
<p className="font-bold">"{title}..."</p>
</Link>
The weird part is that if I swap the "/create" Route with "/blogs/:id" Route, making it third, the app only shows the "/blogs/:id" and then "/create" doesn't show now. Basically the third route doesn't work.