fix: "instant update" feature

- Components do update to values received from backend even if instant
  update is not selected.
This commit is contained in:
Mose Müller
2023-08-02 12:06:22 +02:00
parent 4ff07aa587
commit 7a89168d14
2 changed files with 16 additions and 12 deletions

View File

@@ -21,10 +21,14 @@ export const StringComponent = React.memo((props: StringComponentProps) => {
const { name, parent_path, readOnly, docString, isInstantUpdate } = props;
useEffect(() => {
renderCount.current++;
if (isInstantUpdate && props.value !== inputString) {
}, [isInstantUpdate, inputString, renderCount]);
useEffect(() => {
// Only update the inputString if it's different from the prop value
if (props.value !== inputString) {
setInputString(props.value);
}
}, [isInstantUpdate, props.value, inputString, renderCount]);
}, [props.value]);
const handleChange = (event) => {
setInputString(event.target.value);