Skip to content

🎥 Make videos programmatically with React

fix update value bug

Jonny Burger1dfafe1478a3
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
index 2199fab6ef..a8564254bf 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
@@ -48,7 +48,7 @@ export const ZodArrayEditor: React.FC<{
schema,
jsonPath,
compact,
- setValue: updateValue,
+ setValue,
defaultValue,
value,
onSave,
@@ -94,12 +94,12 @@ export const ZodArrayEditor: React.FC<{
const onChange = useCallback(
(updater: (oldV: unknown[]) => unknown[], incrementRevision: boolean) => {
+ let applyToParent = false;
setLocalValue((oldLocalState) => {
const newValue = updater(oldLocalState.value);
const safeParse = schema.safeParse(newValue);
- // TODO: This logs an error to the console
if (safeParse.success) {
- updateValue(updater);
+ applyToParent = true;
}
return {
@@ -108,8 +108,12 @@ export const ZodArrayEditor: React.FC<{
zodValidation: safeParse,
};
});
+
+ if (applyToParent) {
+ setValue(updater);
+ }
},
- [schema, updateValue]
+ [schema, setValue]
);
const style = useMemo((): React.CSSProperties | undefined => {