@@ -133,7 +133,7 @@ export function getChildren(props, childComponents, calculatedProps) {
133
133
const { origin, horizontal } = calculatedProps ;
134
134
const parentName = props . name || "chart" ;
135
135
136
- return childComponents . map ( ( child , index ) => {
136
+ return childComponents . filter ( React . isValidElement ) . map ( ( child , index ) => {
137
137
const role = child . type && child . type . role ;
138
138
const style = Array . isArray ( child . props . style )
139
139
? child . props . style
@@ -161,11 +161,10 @@ export function getChildren(props, childComponents, calculatedProps) {
161
161
}
162
162
163
163
export const getChildComponents = ( props , defaultAxes ?) => {
164
- const childComponents = React . Children . toArray ( props . children ) ;
165
- let newChildComponents = [ ...childComponents ] ;
164
+ let childComponents = React . Children . toArray ( props . children ) ;
166
165
167
166
if ( childComponents . length === 0 ) {
168
- newChildComponents . push ( defaultAxes . independent , defaultAxes . dependent ) ;
167
+ childComponents . push ( defaultAxes . independent , defaultAxes . dependent ) ;
169
168
} else {
170
169
const axisComponents = {
171
170
dependent : Axis . getAxisComponentsWithParent ( childComponents , "dependent" ) ,
@@ -179,18 +178,18 @@ export const getChildComponents = (props, defaultAxes?) => {
179
178
axisComponents . dependent . length === 0 &&
180
179
axisComponents . independent . length === 0
181
180
) {
182
- newChildComponents = props . prependDefaultAxes
181
+ childComponents = props . prependDefaultAxes
183
182
? [ defaultAxes . independent , defaultAxes . dependent ] . concat (
184
- newChildComponents ,
183
+ childComponents ,
185
184
)
186
- : newChildComponents . concat ( [
185
+ : childComponents . concat ( [
187
186
defaultAxes . independent ,
188
187
defaultAxes . dependent ,
189
188
] ) ;
190
189
}
191
190
}
192
191
193
- return newChildComponents ;
192
+ return childComponents ;
194
193
} ;
195
194
196
195
const getDomain = ( props , axis , childComponents ) => {
0 commit comments