-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Formatic 3000 #124
base: master
Are you sure you want to change the base?
WIP: Formatic 3000 #124
Changes from 1 commit
230f394
8eec2ce
cebd6fa
8f390f4
2c827b3
c5d0bc8
6739955
f23a600
3fe0ad1
f193215
af6e3e0
0fa226e
067a500
8878def
0f4c5d5
0c571f3
018b2b6
221b69c
2476fc3
ace4df5
565da6f
be8de3c
7e5f9bd
abe9f0c
737daa6
dfc5f54
9cc81ac
9218c37
c84bc32
6aeaf24
7d7a3ad
9b6362d
0185cdd
089c4f3
06c06b4
4bc8326
65f7c08
87660c8
a4a0242
4d3981b
302cf96
0b80b23
a08c04a
5e9b175
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,10 @@ export function FormContainer({ | |
const [isControlled] = useState(savedDefaultValue === undefined); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to put this in state? I could see caching the initial value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's effectively what I'm doing here. When you use |
||
const normalizedValue = isControlled ? value : savedDefaultValue; | ||
// Keep context object pure. | ||
const renderContext = useMemo( | ||
() => ({ renderTag, renderComponent, initialValue: normalizedValue }), | ||
[renderTag, renderComponent] | ||
); | ||
const renderContext = useMemo(() => ({ renderTag, renderComponent }), [ | ||
renderTag, | ||
renderComponent, | ||
]); | ||
return ( | ||
<RenderContext.Provider value={renderContext}> | ||
<ReactiveValueContainer onChange={onChange} value={normalizedValue}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevelikesmusic I made an even more performant
ReactiveValue
. (Unfortunately, it did get a bit more complex, but it's still nicely isolated behind hooks.) And as part of that, I added auseReactiveValueMeta
that I swapped out here. It gives you access to property types and only updates when those types change. This is also dynamic, so new properties that are added will generate new auto fields.I think this may be roughly how validation errors will work once we get to that. Effectively, validation errors will just be extra metadata this sits alongside the values.