Fix maximum cycle depth exceeded error
This commit is contained in:
parent
d2c40c1d0d
commit
388e8ff49e
2 changed files with 7 additions and 13 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
|
||||||
|
|
@ -21,8 +21,7 @@ const InputTableField = (props: Props) => {
|
||||||
const [value, setValue] = useState(0)
|
const [value, setValue] = useState(0)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.value !== undefined && props.value !== value)
|
if (props.value) setValue(props.value)
|
||||||
setValue(props.value)
|
|
||||||
}, [props.value])
|
}, [props.value])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -44,7 +43,6 @@ const InputTableField = (props: Props) => {
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
className="Bound"
|
className="Bound"
|
||||||
placeholder={props.placeholder}
|
|
||||||
type="number"
|
type="number"
|
||||||
value={`${value}`}
|
value={`${value}`}
|
||||||
step={1}
|
step={1}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const SliderTableField = (props: Props) => {
|
const SliderTableField = (props: Props) => {
|
||||||
const [value, setValue] = useState(0)
|
const [value, setValue] = useState(props.value)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.value !== undefined && props.value !== value)
|
if (props.value !== undefined && props.value !== value)
|
||||||
|
|
@ -29,7 +29,7 @@ const SliderTableField = (props: Props) => {
|
||||||
}, [props.value])
|
}, [props.value])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
props.onValueChange(value)
|
if (value !== props.value) props.onValueChange(value)
|
||||||
}, [value])
|
}, [value])
|
||||||
|
|
||||||
function handleValueCommit(value: number[]) {
|
function handleValueCommit(value: number[]) {
|
||||||
|
|
@ -40,14 +40,10 @@ const SliderTableField = (props: Props) => {
|
||||||
setValue(value[0])
|
setValue(value[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInputChange(event: React.ChangeEvent<HTMLInputElement>) {
|
function handleInputChange(event: React.ChangeEvent<HTMLInputElement>) {
|
||||||
setValue(parseInt(event.currentTarget?.value))
|
setValue(parseInt(event.currentTarget?.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
function onValueChange(value: number[]) {
|
|
||||||
setValue(value[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableField
|
<TableField
|
||||||
name={props.name}
|
name={props.name}
|
||||||
|
|
@ -63,7 +59,7 @@ const SliderTableField = (props: Props) => {
|
||||||
max={props.max}
|
max={props.max}
|
||||||
step={props.step}
|
step={props.step}
|
||||||
value={[value]}
|
value={[value]}
|
||||||
onValueChange={onValueChange}
|
onValueChange={handleValueChange}
|
||||||
onValueCommit={handleValueCommit}
|
onValueCommit={handleValueCommit}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
|
|
@ -73,7 +69,7 @@ const SliderTableField = (props: Props) => {
|
||||||
min={props.min}
|
min={props.min}
|
||||||
max={props.max}
|
max={props.max}
|
||||||
step={props.step}
|
step={props.step}
|
||||||
onChange={onInputChange}
|
onChange={handleInputChange}
|
||||||
/>
|
/>
|
||||||
</TableField>
|
</TableField>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue