Parsing Attributes
Sometimes it is important to pass additional attributes to the Link component. We can achieve this by passing the props directly to the Link Component. Here in the below example, I have added two additional props such as className for styling the link and target attribute to navigate to the location in new tab.
Syntax to pass attributes:
<Link to = "/home" className="home" target="_blank">
Home
</Link>
Link Component in React Router
React Router is a powerful library in ReactJS that is used to create SPA (single-page applications) seamlessly. One of the components of the React Router is Link.
In this article, we will be seeing the working of the Link component, various props, and usage of the Link component within React Router in developing Single Page Applications.
Table of Content
- Working of Link Component:
- What are Props ?
- What is ‘to’ prop ?
- What is ‘reloadDocument’ prop ?
- What is ‘replace’ prop ?
- What is ‘preventScrollReset’ prop ?
- Parsing Attributes
- Use of Link Component