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