Skip to content

Instantly share code, notes, and snippets.

@kyya
Forked from chibicode/README-Twemoji-React.md
Created December 23, 2020 06:45
Show Gist options
  • Select an option

  • Save kyya/f736e962d50c330673f387e17665b3d5 to your computer and use it in GitHub Desktop.

Select an option

Save kyya/f736e962d50c330673f387e17665b3d5 to your computer and use it in GitHub Desktop.
A dead simple React.js Twemoji component.

Twemoji + React

A dead simple React Twemoji component.

Requirements: twemoji

npm install --save twemoji

# or

yarn add twemoji
import React from 'react'
import Twemoji from './Twemoji'
const Example = () => (
<p>
Hello! <Twemoji emoji="👋" />
</p>
)
export default Example
.emoji {
display: inline-block;
width: auto;
height: 1em;
vertical-align: -0.125em;
}
import React, { memo } from 'react'
import twemoji from 'twemoji'
const Twemoji = ({ emoji }) => (
<span
dangerouslySetInnerHTML={{
__html: twemoji.parse(emoji, {
folder: 'svg',
ext: '.svg'
})
}}
/>
)
export default memo(Twemoji)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment