diff --git a/memento-note/components/markdown-content.tsx b/memento-note/components/markdown-content.tsx
index 5fadd44..ac8a41f 100644
--- a/memento-note/components/markdown-content.tsx
+++ b/memento-note/components/markdown-content.tsx
@@ -1,6 +1,6 @@
'use client'
-import { memo } from 'react'
+import { memo, useMemo } from 'react'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import remarkMath from 'remark-math'
@@ -9,6 +9,11 @@ import rehypeRaw from 'rehype-raw'
import 'katex/dist/katex.min.css'
import { NoteChartFromCode } from './note-chart'
+// Memoized wrapper to prevent infinite re-renders
+const ChartWrapper = memo(function ChartWrapper({ code }: { code: string }) {
+ return
+})
+
interface MarkdownContentProps {
content: string
className?: string
@@ -28,9 +33,10 @@ export const MarkdownContent = memo(function MarkdownContent({ content, classNam
const match = /language-(\w+)/.exec(className || '')
const language = match ? match[1] : ''
- // Chart code blocks
+ // Chart code blocks - memoized to prevent infinite loops
if (language === 'chart') {
- return
+ const chartCode = String(children).replace(/\n$/, '')
+ return
}
// Other code blocks
diff --git a/memento-note/components/note-chart.tsx b/memento-note/components/note-chart.tsx
index 490a8eb..f24f458 100644
--- a/memento-note/components/note-chart.tsx
+++ b/memento-note/components/note-chart.tsx
@@ -182,7 +182,7 @@ function NoteChart({ type, title, data, colors, showLegend, height = 250 }: Note
}
default:
- return
Type de graphique non supporté: {type}
+ return null
}
}
@@ -246,6 +246,6 @@ export function parseChartFromCode(code: string): NoteChartProps | null {
export function NoteChartFromCode({ code }: { code: string }) {
const props = useMemo(() => parseChartFromCode(code), [code])
- if (!props) return Format de graphique invalide
+ if (!props) return null
return
}