ReactJS hide emoji picker when one is open

243 Views Asked by At

I am working on a react component that renders 20/or more instances of a component called "Note". Each note component will have an emoji picker component in it. Which will be opened when the user clicks a button in the note component. The issue I am facing is I don't know how to hide other emoji pickers when one is opened. Currently, the user can click the button on each Note component and open the Emoji picket. I want when the user clicks the button to open an Emoji picker all other open Emojis to close. Please advise.

1

There are 1 best solutions below

0
On

Don't add emoji-picker to all of the items you want to render at the same time. You can create one instance of emoji-picker and store some kind of data to state that stores current node ID or something and show only currentNoteId === note.id item.