-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathindex.tsx
41 lines (32 loc) · 1.69 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, {forwardRef, useImperativeHandle, useRef, useState} from 'react';
import type {ForwardedRef} from 'react';
import type {InnerReactionListRef} from '@hooks/useBasePopoverReactionList/types';
import type {ReactionListRef} from '@pages/home/ReportScreenContext';
import BasePopoverReactionList from './BasePopoverReactionList';
function PopoverReactionList(props: unknown, ref: ForwardedRef<ReactionListRef>) {
const innerReactionListRef = useRef<InnerReactionListRef>(null);
const [reactionListReportActionID, setReactionListReportActionID] = useState('');
const [reactionListEmojiName, setReactionListEmojiName] = useState('');
const showReactionList: ReactionListRef['showReactionList'] = (event, reactionListAnchor, emojiName, reportActionID) => {
setReactionListReportActionID(reportActionID);
setReactionListEmojiName(emojiName);
innerReactionListRef.current?.showReactionList(event, reactionListAnchor);
};
const hideReactionList = () => {
innerReactionListRef.current?.hideReactionList();
};
const isActiveReportAction = (actionID: number | string) => Boolean(actionID) && reactionListReportActionID === actionID;
useImperativeHandle(ref, () => ({showReactionList, hideReactionList, isActiveReportAction}));
if (reactionListReportActionID === '' || reactionListEmojiName === '') {
return null;
}
return (
<BasePopoverReactionList
ref={innerReactionListRef}
reportActionID={reactionListReportActionID}
emojiName={reactionListEmojiName}
/>
);
}
PopoverReactionList.displayName = 'PopoverReactionList';
export default React.memo(forwardRef(PopoverReactionList));