react-tiny-linkify
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

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

import React from 'react'
import linkify from 'react-tiny-linkify'

const Example: React.FC<{ children: string }> = ({ children }) => (
  <p>{linkify(children)}</p>
)

const element = (
  <Example>
    example: https://example.com
  </Example>
)

/*
 * got: ReactElement
 *   <p>
 *     example: <a href="https://example.com">https://example.com</a>
 *   </p>
 */
  • with memo
const Example: React.FC<{ content: string }> = ({ content }) => {
  const linked = useMemo(() => linkify(content), [content])
  return (
    <p>{linked}</p>
  )
}

Readme

Keywords

none

Package Sidebar

Install

npm i react-tiny-linkify

Weekly Downloads

679

Version

1.2.0

License

MIT

Unpacked Size

14.4 kB

Total Files

14

Last publish

Collaborators

  • maxmellon