Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added react wrapper for Emoji element #839

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 })
}
Loading