Skip to content

Commit 2ded8be

Browse files
committed
Fixing use of children as Array
1 parent 2a83817 commit 2ded8be

File tree

1 file changed

+6
-3
lines changed
  • packages/react-google-maps-api/src/components/drawing

1 file changed

+6
-3
lines changed

packages/react-google-maps-api/src/components/drawing/Marker.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { unregisterEvents, applyUpdatersToPropsAndRegisterEvents } from '../../u
55
import MapContext from '../../map-context'
66

77
import { Clusterer } from '@react-google-maps/marker-clusterer'
8+
import { ReactNode } from 'react'
89

910
const eventMap = {
1011
onAnimationChanged: 'animation_changed',
@@ -248,11 +249,13 @@ export class Marker extends React.PureComponent<MarkerProps, MarkerState> {
248249
}
249250

250251
render(): React.ReactNode {
251-
let children: JSX.Element|null = null
252+
let children: ReactNode[]|null = null
252253
if(this.props.children) {
253-
children = this.props.children.map((e) => {return React.cloneElement(e, {anchor: this.state.marker})})
254+
children = React.Children.toArray(this.props.children).map(
255+
(e) => {return React.cloneElement(e, {anchor: this.state.marker})}
256+
)
254257
}
255-
return this.props.children || null
258+
return children || null
256259
}
257260
}
258261

0 commit comments

Comments
 (0)