Skip to content

Commit cfc5796

Browse files
committed
rm unnecessary state
1 parent c031c33 commit cfc5796

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/components/expandable/index.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export function Expandable({
3838

3939
const [isExpanded, setIsExpanded] = useState(false);
4040
const [copied, setCopied] = useState(false);
41-
const [showCopyButton, setShowCopyButton] = useState(false);
4241
const contentRef = useRef<HTMLDivElement>(null);
4342

4443
// Ensure we scroll to the element if the URL hash matches
@@ -67,12 +66,6 @@ export function Expandable({
6766
};
6867
}, [id]);
6968

70-
useEffect(() => {
71-
if (copy) {
72-
setShowCopyButton(true);
73-
}
74-
}, [copy]);
75-
7669
async function copyContentOnClick(event: React.MouseEvent<HTMLButtonElement>) {
7770
event.stopPropagation(); // Prevent the details element from toggling
7871
event.preventDefault(); // Prevent default summary click behavior
@@ -153,8 +146,8 @@ export function Expandable({
153146
onClick={copyContentOnClick}
154147
type="button" // Important for buttons in summaries
155148
>
156-
{showCopyButton && !copied && 'Copy Rules'}
157-
{showCopyButton && copied && 'Copied!'}
149+
{!copied && 'Copy Rules'}
150+
{copied && 'Copied!'}
158151
</button>
159152
)}
160153
</summary>

0 commit comments

Comments
 (0)