Added value reporting and fixed a cycle error
This commit is contained in:
parent
a62db832eb
commit
18aa3d4a4e
3 changed files with 8 additions and 7 deletions
|
|
@ -21,7 +21,8 @@ const InputTableField = (props: Props) => {
|
|||
const [value, setValue] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
if (props.value) setValue(props.value)
|
||||
if (props.value !== undefined && props.value !== value)
|
||||
setValue(props.value)
|
||||
}, [props.value])
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ interface Props {
|
|||
name: string
|
||||
label: string
|
||||
description?: string
|
||||
value?: number
|
||||
value: number
|
||||
className?: string
|
||||
imageAlt?: string
|
||||
imageClass?: string
|
||||
|
|
@ -25,11 +25,11 @@ const SliderTableField = (props: Props) => {
|
|||
|
||||
useEffect(() => {
|
||||
if (props.value !== undefined && props.value !== value)
|
||||
if (props.value) setValue(props.value)
|
||||
setValue(props.value)
|
||||
}, [props.value])
|
||||
|
||||
useEffect(() => {
|
||||
if (value !== undefined && value !== props.value) props.onValueChange(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
|
||||
|
|
@ -20,11 +20,11 @@ const SwitchTableField = (props: Props) => {
|
|||
const [value, setValue] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (props.value) setValue(props.value)
|
||||
if (value !== props.value) setValue(props.value)
|
||||
}, [props.value])
|
||||
|
||||
useEffect(() => {
|
||||
if (value !== undefined) props.onValueChange(value)
|
||||
props.onValueChange(value)
|
||||
}, [value])
|
||||
|
||||
function onValueChange(value: boolean) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue