A React component for converting URLs in a given string of text into clicking link tags.
The original package was published at OpenGov/react-autolink-text, but it seems to have been abandoned so I've published a fork to support ongoing development and keep up with new React versions.
npm install react-autolink-text2
import ReactDOM from 'react-dom';
import AutoLinkText from 'react-autolink-text2';
ReactDOM.render(
<AutoLinkText text='Check out this cool component: http://github.com/schneidmaster/react-autolink-text2' />,
document.body
);text(string) -- text to be autolinked[maxLength](number) -- optional max text length, after which the provided text will be truncated[linkProps](object) -- optional props to be set on generated link elements (target='_blank',rel='nofollow', custom classes, etc.)
- git
- npm
- yarn (optional/recommended)
- Clone the repository (
git clone git@github.com:schneidmaster/react-autolink-text.git) - Install dependencies:
npm installoryarn install
Run npm run examples or yarn examples and open http://localhost:8080. Make changes in src/index.js or try different use cases in examples/app.js.
Run npm test or yarn test to execute the jest test suite. An HTML code coverage report is automatically saved to /coverage/lcov-report/index.html.
Run npm run lint or yarn lint to lint the codebase (using eslint).
Run npm run build or yarn build to build an ES5 version of the package.
- Fork it (https://github.com/schneidmaster/react-autolink-text/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Thank you to @gregjacobs for creating Autolinker.js from which this component was based.