Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

isArraysEqual - causes Uncaught TypeError: Converting circular structure to JSON #55

Closed
rm-hull opened this issue Nov 29, 2017 · 7 comments
Labels
Milestone

Comments

@rm-hull
Copy link
Contributor

rm-hull commented Nov 29, 2017

If I create a marker with that has a popup created with L.popup(), rather than a straight string, then the following error is thrown:

Uncaught TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at isArraysEqual 

I believe it to emanate from https://github.com/YUzhva/react-leaflet-markercluster/blob/32de93f6e38a5c5ce164cc725ea2e86d8cc4f48e/src/react-leaflet-markercluster.js#L59-L68

It is not necessary to open the popup to cause the failure.

I had created the popup very similar to your demos:

function getLeafletPopup(name) {
  return L.popup({ minWidth: 200, closeButton: false })
    .setContent(`
      <div>
        <b>Hello world!</b>
        <p>I am a ${name} popup.</p>
      </div>
    `);
}

and it occurs on removing markers (with the popup) from the map.


Update:

$ grep leaflet package.json 
    "leaflet": "1.2.0",
    "leaflet.markercluster": "1.2.0",
    "react-leaflet": "1.7.5",
    "react-leaflet-markercluster": "1.1.7",
@rm-hull
Copy link
Contributor Author

rm-hull commented Nov 30, 2017

FYI, a tactical fix (that works for me) is: https://github.com/rm-hull/react-leaflet-markercluster/commit/e6d968b978c441f4f688ee9299676d9a6e80a5a1 - there's a good chance it improves performance slightly, as well.

@rm-hull
Copy link
Contributor Author

rm-hull commented Jan 8, 2018

Hey @yuzhva, I've updated the fix to use deepEquals - this seems more robust - is this something you would consider taking as a PR into the library - see https://github.com/rm-hull/react-leaflet-markercluster/commit/7f44ba598663a5bdda6593c6182b18a5ffd3847b ?

@morsh
Copy link

morsh commented Jan 9, 2018

I'm getting the exact same error.
When I remove the popup I stop getting the error.

let markupPopup = (popup && L.popup().setContent(popup)) || null;
markers.push({ lat: 0.1, lng: 0.2, popup: markupPopup });

I tried updating the version of:
"leaflet": "^1.2.0",
"leaflet-geosearch": "^2.6.0",
"leaflet.markercluster": "^1.2.0",
"react-leaflet": "^1.7.8",
"react-leaflet-div-icon": "^1.1.0",
"react-leaflet-markercluster": "^1.1.7",

And I'm still getting this issue.

@rm-hull
Copy link
Contributor Author

rm-hull commented Jan 9, 2018

@morsh - as a temporary measure, in your package.json, replace with:

 "react-leaflet-markercluster": "github:rm-hull/react-leaflet-markercluster",

And test it to see if it fixes your problem

yuzhva pushed a commit that referenced this issue Jan 27, 2018
Using `JSON.stringify()`, when a marker has a popup created with `L.popup()`,
rather than a straight string, then the following error is thrown:

    Uncaught TypeError: Converting circular structure to JSON
        at JSON.stringify (<anonymous>)
        at isArraysEqual

See #55
yuzhva pushed a commit that referenced this issue Jan 27, 2018
Using `JSON.stringify()`, when a marker has a popup created with `L.popup()`,
rather than a straight string, then the following error is thrown:

    Uncaught TypeError: Converting circular structure to JSON
        at JSON.stringify (<anonymous>)
        at isArraysEqual

See #55
@yuzhva
Copy link
Owner

yuzhva commented Mar 8, 2018

@rm-hull Maybe you know some tool, which I could use to add your profile to README.md with your avatar?
P.S: Don't want to seems lazy, just hope you know one of that, before I google it (=

@rm-hull
Copy link
Contributor Author

rm-hull commented Mar 8, 2018

Adding <img src="https://avatars1.githubusercontent.com/u/1915543?s=460&v=4" width="50" height="50" /> works:

@rm-hull
Copy link
Contributor Author

rm-hull commented Mar 8, 2018

Fixed by #58

@rm-hull rm-hull closed this as completed Mar 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants