fix: fix the violation by moving useState to the top

This commit is contained in:
Sayo
2025-10-31 08:25:44 +08:00
parent 74607971a2
commit a39a5fdd97

View File

@@ -197,6 +197,7 @@ const safeLocalStorage = {
// Common markdown components to ensure consistent rendering (tables, inline code, links, etc.)
const markdownComponents = {
code: ({ node, inline, className, children, ...props }) => {
const [copied, setCopied] = React.useState(false);
const raw = Array.isArray(children) ? children.join('') : String(children ?? '');
const looksMultiline = /[\r\n]/.test(raw);
const inlineDetected = inline || (node && node.type === 'inlineCode');
@@ -213,7 +214,6 @@ const markdownComponents = {
</code>
);
}
const [copied, setCopied] = React.useState(false);
const textToCopy = raw;
const handleCopy = () => {