Update TableFields to not error
Also optional value is required
This commit is contained in:
parent
e67a8aa359
commit
e36de8389e
3 changed files with 6 additions and 6 deletions
|
|
@ -8,7 +8,7 @@ interface Props {
|
|||
name: string
|
||||
label: string
|
||||
description?: string
|
||||
value: number
|
||||
value?: number
|
||||
className?: string
|
||||
imageAlt?: string
|
||||
imageClass?: string
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ interface Props {
|
|||
name: string
|
||||
label: string
|
||||
description?: string
|
||||
value: number
|
||||
value?: number
|
||||
className?: string
|
||||
imageAlt?: string
|
||||
imageClass?: string
|
||||
|
|
@ -29,7 +29,7 @@ const SliderTableField = (props: Props) => {
|
|||
}, [props.value])
|
||||
|
||||
useEffect(() => {
|
||||
if (value !== props.value) props.onValueChange(value)
|
||||
if (value !== undefined && value !== props.value) props.onValueChange(value)
|
||||
}, [value])
|
||||
|
||||
function handleValueCommit(value: number[]) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ interface Props {
|
|||
name: string
|
||||
label: string
|
||||
description?: string
|
||||
value: boolean
|
||||
value?: boolean
|
||||
className?: string
|
||||
imageAlt?: string
|
||||
imageClass?: string
|
||||
|
|
@ -17,14 +17,14 @@ interface Props {
|
|||
}
|
||||
|
||||
const SwitchTableField = (props: Props) => {
|
||||
const [value, setValue] = useState(false)
|
||||
const [value, setValue] = useState(props.value)
|
||||
|
||||
useEffect(() => {
|
||||
if (value !== props.value) setValue(props.value)
|
||||
}, [props.value])
|
||||
|
||||
useEffect(() => {
|
||||
props.onValueChange(value)
|
||||
if (value !== undefined) props.onValueChange(value)
|
||||
}, [value])
|
||||
|
||||
function onValueChange(value: boolean) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue