mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-06-04 11:14:10 +08:00
fix: workflow page throw warning: Attempts to access this ref will fail (#12166)
This commit is contained in:
parent
89ce9a5db2
commit
eb8963a673
@ -11,7 +11,9 @@ type SwitchProps = {
|
|||||||
className?: string
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const Switch = ({ onChange, size = 'md', defaultValue = false, disabled = false, className }: SwitchProps) => {
|
const Switch = React.forwardRef(
|
||||||
|
({ onChange, size = 'md', defaultValue = false, disabled = false, className }: SwitchProps,
|
||||||
|
propRef: React.Ref<HTMLButtonElement>) => {
|
||||||
const [enabled, setEnabled] = useState(defaultValue)
|
const [enabled, setEnabled] = useState(defaultValue)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEnabled(defaultValue)
|
setEnabled(defaultValue)
|
||||||
@ -38,6 +40,7 @@ const Switch = ({ onChange, size = 'md', defaultValue = false, disabled = false,
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<OriginalSwitch
|
<OriginalSwitch
|
||||||
|
ref={propRef}
|
||||||
checked={enabled}
|
checked={enabled}
|
||||||
onChange={(checked: boolean) => {
|
onChange={(checked: boolean) => {
|
||||||
if (disabled)
|
if (disabled)
|
||||||
@ -63,7 +66,7 @@ const Switch = ({ onChange, size = 'md', defaultValue = false, disabled = false,
|
|||||||
/>
|
/>
|
||||||
</OriginalSwitch>
|
</OriginalSwitch>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
Switch.displayName = 'Switch'
|
Switch.displayName = 'Switch'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user