-
Notifications
You must be signed in to change notification settings - Fork 2.3k
FieldTemplate children are in an array #1159
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
Comments
Confirming, update to 1.3.0 broked my own field templates, so I reverted back to 1.1.0 |
@epicfaace Is something wrong with an array to be a React children? I think React children can be an array. |
@Kexin-Li that's true, good point -- but in the case shown, items 1 and 2 are |
Without seeing how your Why we have 2 additional nulls here? Because after #1118 #1133 2 conditional fields were added:
To verify open "Any Of" example and you'll see out of those 3 elements only one is |
@ivarprudnikov I see... do you have a suggestion on how to fix this / are you willing to implement a fix? |
@epicfaace what I was saying that it is not a bug, it's a normal thing in React and when developer handles elements he almost always needs to make sure it is either an element or an array of elements with nulls as placeholders. If developer wants to get only valid children then they could use const myChildren = React.Children.toArray(props.children); Method interface: interface ReactChildren {
// skip other methods for brevity
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
} |
@ivarprudnikov I see what you mean, but it might be good to wrap them in a |
It depends and in theory could be a breaking change. If anyone was cloning Also it is not clear what issue creator @mlbstrm was doing with In addition to the above if this is something meant only for |
fixed by #1709 |
Uh oh!
There was an error while loading. Please reload this page.
Prerequisites
Description
Since release 1.2.0 (and more specifically #1118), children passed to FieldTemplate are in an array.
Steps to Reproduce
Expected behavior
children
should be a node.Actual behavior
children
is an Array with 2 extra null items.Version
1.2.0
The text was updated successfully, but these errors were encountered: