Created
December 29, 2018 06:34
-
-
Save developerruhul/685dc291a84da19d61a503b596126fc9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import {Link} from 'react-router-dom'; | |
| export const renderText = text => { | |
| let parts = text.split(/#(\S*)/g); | |
| for (let i = 1; i < parts.length; i += 2) { | |
| parts[i] = ( | |
| <Link key={"link" + i} to={`/hashed/${parts[i]}`}> | |
| #{parts[i]} | |
| </Link> | |
| ); | |
| } | |
| return parts; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment