Answer the question
In order to leave comments, you need to log in
How to remove hash(#) from react-router-dom path?
Hello, tell me how to remove # from my path.
Now it's like this: localhost:3000/#/details/test , but it should be localhost:3000/details/test
<HashRouter>
<div>
<Route path="/" exact component={Home} />
<Route path="/details/:service" component={Service} />
</div>
</HashRouter>
...
{servicesList.map((service, index) => (
<tr
onClick={() => {
history.push("/details/" + service);
}}
key={service}
>
<td>{service}</td>
</tr>
))}
...
Answer the question
In order to leave comments, you need to log in
You are using the HashRouter component, hence the hashes in the address bar. For your task, BrowserRouter is suitable for you. For links, use the Link
component
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question