0.3.0 • Published 7 years ago

@ufotsuboi/react-string2tag v0.3.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

React String to Tag

To replace 'http://~' and '\n' in the string to each tags for React.js.

Install

$ npm install @ufotsuboi/react-string2tag

Usage

import React from 'react';
import string2tag from '@ufotsuboi/react-string2tag';

const testString = 'foo\nhttps://github.com/ufotsuboi/react-string2tag\nbar';

const Show = ({ text }) => {
  return (
    <div>
      {string2tag(text)}
    </div>
  );
};
string2tag(text, {
  link: {
    className: 'hoge',
    targetBlank: false,
    ellipsisi: 25,
  },
});

Options

  • link
    • className: Add class attribute to 'a' tags.
    • targetBlank: Default true.
    • ellipsis: Omitted if url is longer than it. Default false.

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago