Use a fork of autolinker with react support to get rid off dangerouslySetInnerHTML

This commit is contained in:
Ken-Håvard Lieng 2016-02-17 01:49:27 +01:00
parent 072daa64f2
commit 47ebd9c84c
6 changed files with 44 additions and 27 deletions

View file

@ -0,0 +1,17 @@
import Autolinker from 'autolinker';
import React from 'react';
const autolinker = new Autolinker({
stripPrefix: false,
doJoin: false,
replaceFn: (linker, match) => {
if (match.getType() === 'url') {
return <a target="_blank" href={match.getAnchorHref()}>{match.getAnchorText()}</a>;
}
},
React
});
export default function linkify(text) {
return autolinker.link(text);
}