https://github.com/maxmellon/react-tiny-linkify
A library convert to anchor tag from text children as react component. (< 1KB)
https://github.com/maxmellon/react-tiny-linkify
Last synced: 4 months ago
JSON representation
A library convert to anchor tag from text children as react component. (< 1KB)
- Host: GitHub
- URL: https://github.com/maxmellon/react-tiny-linkify
- Owner: MaxMEllon
- Created: 2021-07-02T09:50:49.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T01:36:27.000Z (over 2 years ago)
- Last Synced: 2024-10-15T04:32:51.776Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 169 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-tiny-linkify
> A library convert to anchor tag from text children as react component.
- very tiny
- simple usage
- so simple
- - -
## Instillation
```
$ npm i react-tiny-linkify
```
## Usage
```jsx
import React from 'react'
import linkify from 'react-tiny-linkify'
const Example: React.FC<{ children: string }> = ({ children }) => (
{linkify(children)}
)
const element = (
example: https://example.com
)
/*
* got: ReactElement
*
* example: https://example.com
*
*/
```
- with memo
```jsx
const Example: React.FC<{ content: string }> = ({ content }) => {
const linked = useMemo(() => linkify(content), [content])
return (
{linked}
)
}
```