-
Notifications
You must be signed in to change notification settings - Fork 42
fix CustomChildComponent remount #131
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
fix CustomChildComponent remount #131
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
=> {}} | ||
> | ||
{(fields) => { | ||
const { isDirty } = useFormState(); |
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.
i added this to the test and made it work, but maybe the assumption should be that it doesn't? I think hooks strictly speaking are not completely safe to use in a render prop..
renderedFields, | ||
}: { | ||
renderedFields: RenderedFieldMap<SchemaType>; | ||
CustomChildrenComponent?: FunctionComponent<RenderedFieldMap<SchemaType>>; |
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.
is this really a FunctionComponent
? isn't it just a function? it's a render prop not a component yeah?
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.
Oh good point! That's the whole reason for this change lol :)
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.
lgtm!
gonna go ahead and merge this since it's a bug fix |
Noticed that having a function as child rendered as a component was causing the whole form to rerender on some kinds of changes. Call the function as a function instead to avoid this bug. Added a test to prove the issue and fixed.
Note: this does mean our custom child has all the limitations of a normal render prop, but I think that should have already been implied. If a true component is needed it can be rendered from within the function.