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)
|
const [value, setValue] = useState(0)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.value) setValue(props.value)
|
if (props.value !== undefined && props.value !== value)
|
||||||
|
setValue(props.value)
|
||||||
}, [props.value])
|
}, [props.value])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -25,11 +25,11 @@ const SliderTableField = (props: Props) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.value !== undefined && props.value !== value)
|
if (props.value !== undefined && props.value !== value)
|
||||||
if (props.value) setValue(props.value)
|
setValue(props.value)
|
||||||
}, [props.value])
|
}, [props.value])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value !== undefined && value !== props.value) props.onValueChange(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
|
||||||
|
|
@ -20,11 +20,11 @@ const SwitchTableField = (props: Props) => {
|
||||||
const [value, setValue] = useState(false)
|
const [value, setValue] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.value) setValue(props.value)
|
if (value !== props.value) setValue(props.value)
|
||||||
}, [props.value])
|
}, [props.value])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value !== undefined) props.onValueChange(value)
|
props.onValueChange(value)
|
||||||
}, [value])
|
}, [value])
|
||||||
|
|
||||||
function onValueChange(value: boolean) {
|
function onValueChange(value: boolean) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue