Refactor:upgrade react19 ref as props (#25225)

Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
This commit is contained in:
zyileven 2025-09-08 09:46:02 +08:00 • committed by GitHub
commit 98204d78fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 83 additions and 78 deletions

View file

@ -107,10 +107,13 @@ const initMermaid = () => {
return isMermaidInitialized
}
const Flowchart = React.forwardRef((props: {
type FlowchartProps = {
PrimitiveCode: string
theme?: 'light' | 'dark'
}, ref) => {
ref?: React.Ref<HTMLDivElement>
}
const Flowchart = (props: FlowchartProps) => {
const { t } = useTranslation()
const [svgString, setSvgString] = useState<string | null>(null)
const [look, setLook] = useState<'classic' | 'handDrawn'>('classic')
@ -490,7 +493,7 @@ const Flowchart = React.forwardRef((props: {
}
return (
<div ref={ref as React.RefObject<HTMLDivElement>} className={themeClasses.container}>
<div ref={props.ref as React.RefObject<HTMLDivElement>} className={themeClasses.container}>
<div className={themeClasses.segmented}>
<div className="msh-segmented-group">
<label className="msh-segmented-item m-2 flex w-[200px] items-center space-x-1">
@ -572,7 +575,7 @@ const Flowchart = React.forwardRef((props: {
)}
</div>
)
})
}
Flowchart.displayName = 'Flowchart'