question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

emoji-mart rendering duplicate emoji pickers

See original GitHub issue

have recently started using this package. Followed instructions but whenever I call on emoji-mart it displays two emoji-pickers instead of one.

import React, { useEffect, useRef } from 'react'
import { render } from 'react-dom'

import data from '@emoji-mart/data'
import { Picker } from 'emoji-mart'

export default function Test() {
    function EmojiPicker(props) {
        const ref = useRef()
      
        useEffect(() => {
          new Picker({ ...props, data, ref })
        }, [])
      
        return <div ref={ref} />
      }

    return(
        <EmojiPicker onEmojiSelect={console.log} />
    )
}

Screenshot 2022-06-10 003412

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

2reactions
CSFlorincommented, Jun 17, 2022

Refs keep their value in the mount-unmount-mount pattern in React 18 strict mode so you can do

const executedRef = useRef(false);
useEffect(() => {
  if (executedRef.current) return;
  new Picker({});
  executedRef.current = true;
}, []);
2reactions
vadholovincommented, Jun 17, 2022

The bug occurs in React Strict mode.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emoji Picker | Stream Chat - React SDK Docs - GetStream.io
The default EmojiPicker renders individual emoji objects using the NimbleEmoji component from emoji-mart. Our custom set of emojis will need to follow the ......
Read more >
Next.js, loading a library client side, the component is re ...
I'm loading this library emoji-mart client side because it requires window object and then returning a component, while calling, ...
Read more >
react-emoji-mart-picker - npm package - Snyk
emoji picker based on emoji-mart For more information about how to use this package see README · Ensure you're using the healthiest npm...
Read more >
Customizable Slack-like emoji picker for React
Emoji Mart. Emoji Mart is a Slack-like customizable emoji picker component for React. ... native, false, Renders the native unicode emoji.
Read more >
Adding emojis to your React app - LogRocket Blog
Emoji usage in React · To copy and paste the emoji inline: 😃 · To reference the Unicode identifier/mapping of the emoji HTML...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found