@schaapdigitalcreatives/react-router-innerhtml-links
v2.0.4
Published
Handle innerHTML links the React Router way.
Downloads
2
Keywords
Readme
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 --save
Using Yarn:
yarn add react-router-innerhtml-links
How 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>