Fix mention hook order (#214)
This commit is contained in:
parent
51b85b5b49
commit
2e028c468e
|
@ -25,17 +25,16 @@ export function Mention({ id, setMentioned, className }: MentionProps) {
|
||||||
const [showMenu, setShowMenu] = useState(false);
|
const [showMenu, setShowMenu] = useState(false);
|
||||||
const identity = useIdentity();
|
const identity = useIdentity();
|
||||||
|
|
||||||
if (!contact) return <>{id}</>;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (identity) {
|
if (identity && contact) {
|
||||||
if (contact.id === utils.bufToHex(identity.publicKey)) setMentioned(true);
|
if (contact.id === utils.bufToHex(identity.publicKey)) setMentioned(true);
|
||||||
}
|
}
|
||||||
}, [contact.id, identity]);
|
}, [contact, identity]);
|
||||||
|
|
||||||
const ref = useRef(null);
|
const ref = useRef(null);
|
||||||
useClickOutside(ref, () => setShowMenu(false));
|
useClickOutside(ref, () => setShowMenu(false));
|
||||||
|
|
||||||
|
if (!contact) return <>{id}</>;
|
||||||
return (
|
return (
|
||||||
<MentionBLock
|
<MentionBLock
|
||||||
onClick={() => setShowMenu(!showMenu)}
|
onClick={() => setShowMenu(!showMenu)}
|
||||||
|
|
Loading…
Reference in New Issue