Please do not post unformatted code into issues, and please do not ask questions. Only real issues, PR's or feature requests are allowed. Minimal reproduction in codesandbox.io is required.
src/components/GoogleMapContainer/GoogleMapContainer.tsx:152:13 - error TS2769: No overload matches this call.
Overload 1 of 2, '(props: MarkerClustererProps | Readonly<MarkerClustererProps>): ClustererComponent', gave the following error.
Type 'Element[]' is missing the following properties from type 'ReactElement<any, any>': type, props, key
Overload 2 of 2, '(props: MarkerClustererProps, context: any): ClustererComponent', gave the following error.
Type 'Element[]' is not assignable to type 'Element'.
152 pinList.map((pin) => (
~~~~~~~~~~~~~~~~~~~~~~
153 <Marker
~~~~~~~~~~~~~~~~~~~~~
...
173 </Marker>
~~~~~~~~~~~~~~~~~~~~~~~
174 ))
~~~~~~~~~~~~~~
Found 1 error in src/components/GoogleMapContainer/GoogleMapContainer.tsx:152
If we attempt to map elements directly as a child of the MarkerClustererComponent as shown below:
Issue template
You can donate or became a sponsor https://opencollective.com/react-google-maps-api#category-CONTRIBUTE
If you want to ask question, please ask it in Github Discussions, Spectrum.chat or Slack channel
Please do not post unformatted code into issues, and please do not ask questions. Only real issues, PR's or feature requests are allowed. Minimal reproduction in codesandbox.io is required.
Please provide an explanation of the issue
After updating our @react-google-maps/api package from 2.8.1 -> 2.17.1, we've discovered that our previous code was throwing TypeScript issues due to the
children
component no longer accepting an array ofJSX.Element
, as seen here: https://github.com/JustFly1984/react-google-maps-api/blob/9840eee1f3f09391c23fe4117e8b1e5592c94cdc/packages/react-google-maps-api/src/components/addons/MarkerClusterer.tsx#L102.This is inconsistent with the example in the documentation here:
Your Environment
os: Mac
node --version: 16.15.0
react version: 17.0.2
webpack version: 5.73.0
@babel version: 7.18.5
@react-google-maps/api version: 2.17.1
How does it behave?
It throws a TypeScript error as shown below:
If we attempt to map elements directly as a child of the MarkerClustererComponent as shown below:
How should it behave correctly?
It should properly accept either
JSX.Element
orJSX.Element[]
.Basic implementation of incorrect behavior in codesandbox.com
Apologies I do not have time to implement this now, but will do it in a bit when I do.