Unverified Commit 16905664 authored by boojack's avatar boojack Committed by GitHub

chore: update emoji picker (#483)

parent a24b8852
import Picker, { IEmojiPickerProps } from "emoji-picker-react"; import Picker, { IEmojiPickerProps } from "emoji-picker-react";
import { useEffect } from "react"; import { useEffect, useState } from "react";
interface Props { interface Props {
shouldShow: boolean; shouldShow: boolean;
...@@ -7,8 +7,15 @@ interface Props { ...@@ -7,8 +7,15 @@ interface Props {
onShouldShowEmojiPickerChange: (status: boolean) => void; onShouldShowEmojiPickerChange: (status: boolean) => void;
} }
interface State {
hasShown: boolean;
}
export const EmojiPicker: React.FC<Props> = (props: Props) => { export const EmojiPicker: React.FC<Props> = (props: Props) => {
const { shouldShow, onEmojiClick, onShouldShowEmojiPickerChange } = props; const { shouldShow, onEmojiClick, onShouldShowEmojiPickerChange } = props;
const [state, setState] = useState<State>({
hasShown: false,
});
useEffect(() => { useEffect(() => {
if (shouldShow) { if (shouldShow) {
...@@ -25,13 +32,20 @@ export const EmojiPicker: React.FC<Props> = (props: Props) => { ...@@ -25,13 +32,20 @@ export const EmojiPicker: React.FC<Props> = (props: Props) => {
capture: true, capture: true,
once: true, once: true,
}); });
setState({
hasShown: true,
});
} }
}, [shouldShow]); }, [shouldShow]);
return ( return (
<>
{state.hasShown && (
<div className={`emoji-picker ${shouldShow ? "" : "hidden"}`}> <div className={`emoji-picker ${shouldShow ? "" : "hidden"}`}>
<Picker onEmojiClick={onEmojiClick} disableSearchBar /> <Picker onEmojiClick={onEmojiClick} disableSearchBar />
</div> </div>
)}
</>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment