react-yandex-maps
react-yandex-maps copied to clipboard
TypeError: Cannot read property 'setCoordinates' of null
Error text
react-dom.production.min.js:4636 TypeError: Cannot read property 'setCoordinates' of null
at Function.t.updateObject (react-yandex-maps.esm.js:1054)
at t.componentDidUpdate (react-yandex-maps.esm.js:1025)
at react-dom.production.min.js:6326
at t.unstable_runWithPriority (scheduler.production.min.js:270)
at Ko (react-dom.production.min.js:2794)
at ws (react-dom.production.min.js:6105)
at Es (react-dom.production.min.js:5408)
at react-dom.production.min.js:2829
at t.unstable_runWithPriority (scheduler.production.min.js:270)
at Ko (react-dom.production.min.js:2794)
I use GeoObject
<GeoObject
geometry={{
type: 'Point',
coordinates: [
lat,
lng,
],
}}
properties={{
iconContent: small ? undefined : caption,
}}
options={{
preset: small ? 'islands#circleDotIcon' : 'islands#blueStretchyIcon',
}}
/>
Error goes from BaseGeoObject
's updateObject
function.
https://github.com/gribnoysup/react-yandex-maps/blob/04db88dfe52cfb2d3a07467a6501b407f1ef2ef3/src/geo-objects/BaseGeoObject.js#L81-L100
Shoul I preload some module or something? Or it was just some random glitch?
Found it. It was not GeoObject's but Polyline's fault. Which is extended from BaseGeoObject too. https://codesandbox.io/s/naughty-elion-m7nfh
For now I'm fixed this with {waypoints && <Polyline...
.
But this, probably, should be fixed or TypeScript type should be corrected. Now geometry is optional.
export interface GeoObjectProps<G, P = AnyObject, O = AnyObject>
extends AnyObject {
geometry?: G;
...
Can you help to fix this issue gribnoysup i had also this kind of issue when filtering geobjects?
I think this is not related to typescript. I made some investigation on it. So if you pass null or undefined as geometry: https://github.com/gribnoysup/react-yandex-maps/blob/04db88dfe52cfb2d3a07467a6501b407f1ef2ef3/src/geo-objects/BaseGeoObject.js#L48
Yandex Maps will create object without geometry prop and will break updating logic. As workaround you can pass empty array as initial state.