We are building an application using React JS and dot net core and ant design. The developer instead of making links, he used
<p onClick={()=>dispatch(push("/"))}>home</p>
The reason provided is that this way page doesn't posts back, hence browsing between pages is much faster. I am not sure if this is a valid reason, I guess the right way might be:
<button type="link" onClick={()=>dispatch(push("/"))}>home</button>
OR
<a href="/">home</a>
Kindly advice what is the right way, since I am new to React and Ant Design. Thank you.
After the comment discussion, since you are using the react-router, you can use the components, provided by the react-router library, such as Link
and NavLink
.
An equivalent use to your example would be
<Link to="/">home</Link>