Skip to content

feat(Form): pass only the values named in deps to the render function of a dynamic field - #136

Open
gdevenyi wants to merge 1 commit into
mainfrom
feat/dynamic-field-deps-values
Open

gdevenyi wants to merge 1 commit into
mainfrom
feat/dynamic-field-deps-values

Conversation

@gdevenyi

Copy link
Copy Markdown
Contributor

Summary

 <DynamicField>
   dependentValues = pick(values, field.deps)
   staticField = useMemo(
-    () => field.render(values),
+    () => field.render(dependentValues),
     [dependentValues, field.render])

 resolveStaticFormFields(content, data)
-  field.render(data)
+  field.render(pick(data, field.deps))

render runs again only when a value in deps changes. A value that is not in deps was thus out of date when render read it. Now render does not get it. The types do not change.

Evidence

  • Before: the new test in Form.test.tsx fails on main (field c has deps: ['a']):
    × dynamic field deps > should pass only the values named in deps to the render function
    AssertionError: expected { c: undefined, b: 'abc', a: true } to strictly equal { a: true }
    
    After: pnpm test: 42 files, 247 tests pass. pnpm lint passes.

Merge Danger

Door: two-way

Blast Radius: instruments

A dynamic field that reads a value not named in its deps now gets undefined. Before, it got a value that could be out of date. Such a field must add the key to deps. The type of the render parameter still permits all keys, so TypeScript does not find this error.

Closes #24

🤖 Generated with Claude Code

https://claude.ai/code/session_01W53iUP9ECVtoteopM7QtC7

… of a dynamic field

Closes #24

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W53iUP9ECVtoteopM7QtC7
@gdevenyi
gdevenyi requested a review from joshunrau as a code owner November 10, 2026 04:32
Copilot AI balanced review requested due to automatic review settings November 10, 2026 04:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When rendering a dynamic field, pass only the subset of data specified in deps

2 participants