Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resium Duplicates KML while in React StrictMode #623

Open
TMarche opened this issue Aug 18, 2023 · 4 comments
Open

Resium Duplicates KML while in React StrictMode #623

TMarche opened this issue Aug 18, 2023 · 4 comments

Comments

@TMarche
Copy link

TMarche commented Aug 18, 2023

I've encountered an issue with Resium in StrictMode on the following Resium versions:

  • 1.16.1
  • 1.17.1

Resium will duplicate KML while in StrictMode.

Steps to Replicate

These are the steps I used to replicate the issue.

  1. Run npx create-react-app test-resium-duplication --template typescript
  2. Inside the test-resium-duplication project, run npm install --save @craco/craco craco-cesium cesium resium@1.17.1
  3. Follow steps 3 and 4 here to set up craco
  4. Replace the code in App.tsx with the following:
function App() {
  const kmlBlob = new Blob([
    '<kml xmlns="http://earth.google.com/kml/2.1"><GroundOverlay><color>55ffff</color><name>Region</name><LatLonBox><north>45</north><south>25</south><east>-80</east><west>-100</west></LatLonBox></GroundOverlay></kml>'
  ])

  return (
    <Viewer>
      <KmlDataSource
        data={kmlBlob}
      />
    </Viewer>
  );
}
  1. Start the app
  2. Open the React DevTools "Components" tab
  3. In the Components tab, navigate to App > Viewer > Context.Provider
  4. With Context.Provider Selected, select props > value > viewer > _dataSourceCollection > _dataSources
  5. When in StrictMode, under _dataSources you will see:
    image
  6. Disable StrictMode (remove the React.StrictMode tags from index.tsx). Under _dataSources you will see:
    image
@TimonSotiropoulos
Copy link

+1 for this!

I am getting an entire duplication of the <Viewer></Viewer> component when using React.StrictMode on a brand new project.

@vxlk
Copy link

vxlk commented Nov 2, 2023

Bump. Getting the same issue.

@akHend22
Copy link

akHend22 commented Nov 2, 2023

+1, same issue.

@prusswan
Copy link

prusswan commented Nov 4, 2023

The issue happens to all layers(?) under Viewer. I was wondering why onLayerAdd (under ImageryLayerCollection) was triggered 4 times for every layer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants