1.2.8 • Published 5 years ago
react-router-innerhtml-links v1.2.8
React Router innerHTML Links
Used to let innerHTML links be handled the react-router way. For example links created in WordPress' wysiwyg editor.
Installation
Using NPM:
npm install react-router-innerhtml-links --saveUsing Yarn:
yarn add react-router-innerhtml-linksHow to use
Import
Import the class in the component that needs it.
import Links from 'react-router-innerhtml-links';Mount
Run it on mount. Bind it to the component so that you can run it on Unmount again to remove listeners.
Accepts two parameters
- An element ref (docs).
- Browser history.
componentDidMount() {
this.links = new Links(this.div, storeHistory);
}Unmount
Remove event listeners.
componentWillUnmount() {
this.links.removeListeners();
}Exclude
You can exclude links in elements by adding a data-nolinks attribute to the parent.
<div data-nolinks>
<a href="#">Excluded link</a>
</div>