Skip to content

Commit

Permalink
Added react wrapper for Emoji element
Browse files Browse the repository at this point in the history
  • Loading branch information
galash13 committed Jul 5, 2023
1 parent d29728f commit 210d2bf
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/emoji-mart-react/react.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
import React, { useEffect, useRef } from 'react'
import { Picker } from 'emoji-mart'
import { Emoji, Picker } from 'emoji-mart'

export default function EmojiPicker(props) {
const ref = useRef(null)
Expand All @@ -20,3 +20,22 @@ export default function EmojiPicker(props) {

return React.createElement('div', { ref })
}

export function EmojiElement(props) {
const ref = useRef(null)
const instance = useRef(null)

if (instance.current) {
instance.current.update(props)
}

useEffect(() => {
instance.current = new Emoji({ ...props, ref })

return () => {
instance.current = null
}
}, [])

return React.createElement('span', { ref })
}

0 comments on commit 210d2bf

Please sign in to comment.