banyan / react-emoji

An emoji mixin for React
MIT License
197 stars 40 forks source link

Use Reacts component API #18

Open vinnymac opened 8 years ago

vinnymac commented 8 years ago

I am wondering if an API such as this would be of interest. It would be possible to add a component alongside the mixin. It gives people options. What do you think?

let App = React.createClass({
  getDefaultProps() {
    return {
      text: "foo bar :100: :)",
    };
  },

  render() {
    return (
      <div>
        <span>
          <ReactEmoji text = {this.props.text} />
        </span>
      </div>
    );
  }
});

The props would be everything listed here.

banyan commented 8 years ago

@vinnymac

Sounds good :smile:

vinnymac commented 8 years ago

@banyan I started work on it, and it is going well, doing some tests now.

The revised idea is something like this. Thoughts?

// you can still access the mixin and emojify method.
import ReactEmoji, {ReactEmojiMixin, emojify} from 'react-emoji';

let App = React.createClass({
  getDefaultProps() {
    return {
      text: "foo bar :100: :)",
    };
  },

  render() {
    return (
      <div>
        <span>
          <ReactEmoji emojiType = 'emojione'>
            {this.props.text}
          </ReactEmoji>
        </span>
      </div>
    );
  }
});