-
Notifications
You must be signed in to change notification settings - Fork 835
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
emoji-mart rendering duplicate emoji pickers #617
Comments
The bug occurs in React Strict mode. |
Is there a workaround available for now? |
Refs keep their value in the mount-unmount-mount pattern in React 18 strict mode so you can do
|
Is there a workaround available for now? |
I've fixed it like that export default ({ onSelect, parentId, darkMode, ...props }) => {
const ref: any = useRef()
useEffect(() => {
if (ref.current) ref.current.innerHTML = "" // clean current emoji picker
new Picker({
data: async () => {
const response = await fetch("https://cdn.jsdelivr.net/npm/@emoji-mart/data")
return response.json()
},
ref,
onEmojiSelect: onSelect,
searchPosition: "top",
previewPosition: "none",
navPosition: "top",
autoFocus: true,
theme: darkMode ? "dark" : "light",
title: "",
emoji: "",
maxFrequentRows: 0,
sheetSize: 32,
perLine: 10,
color: "#4285f4",
...props
})
}, [parentId]) // update only when parentId changes
const renderEmojiPickerLoader = () => (
<EmojiPickerLoader>
<Skeleton.Button active={true} block={true} />
</EmojiPickerLoader>
)
return (
<Suspense fallback={renderEmojiPickerLoader()}>
<div className={props.darkMode ? "dark" : ""} ref={ref} />
</Suspense>
)
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
have recently started using this package. Followed instructions but whenever I call on emoji-mart it displays two emoji-pickers instead of one.
The text was updated successfully, but these errors were encountered: