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
|
||||
}
|
||||
|
||||
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)
|
||||
useEffect(() => {
|
||||
setEnabled(defaultValue)
|
||||
@ -38,6 +40,7 @@ const Switch = ({ onChange, size = 'md', defaultValue = false, disabled = false,
|
||||
}
|
||||
return (
|
||||
<OriginalSwitch
|
||||
ref={propRef}
|
||||
checked={enabled}
|
||||
onChange={(checked: boolean) => {
|
||||
if (disabled)
|
||||
@ -63,7 +66,7 @@ const Switch = ({ onChange, size = 'md', defaultValue = false, disabled = false,
|
||||
/>
|
||||
</OriginalSwitch>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
Switch.displayName = 'Switch'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user