fix(challenge modal): react-draggable requires nodeRef in React StrictMode

This commit is contained in:
plebeius.eth
2024-04-28 19:01:53 +02:00
parent 75774e5a38
commit ef1580e8c0
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useRef, useState } from 'react';
import Draggable from 'react-draggable';
import { useTranslation } from 'react-i18next';
import { Challenge as ChallengeType } from '@plebbit/plebbit-react-hooks';
@@ -50,9 +50,12 @@ const Challenge = ({ challenge, closeModal }: ChallengeProps) => {
}
};
// react-draggable requires a ref to the modal node
const nodeRef = useRef(null);
return (
<Draggable handle='.challengeHandle'>
<div className={styles.container}>
<Draggable handle='.challengeHandle' nodeRef={nodeRef}>
<div className={styles.container} ref={nodeRef}>
<div className={`challengeHandle ${styles.title}`}>
Challenge for {publicationType}
<button className={styles.closeIcon} onClick={closeModal} title='close' />