Update TableFields to not error

Also optional value is required
This commit is contained in:
Justin Edmund 2023-03-18 13:54:17 -07:00
parent 388e8ff49e
commit d916658072
3 changed files with 6 additions and 6 deletions

View file

@ -9,7 +9,7 @@ interface Props {
label: string
description?: string
placeholder?: string
value: number
value?: number
className?: string
imageAlt?: string
imageClass?: string

View file

@ -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[]) {

View file

@ -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) {