sitek94 / pocket-globe-app

Use the draggable and zoomable globe to explore the countries of the world.
https://sitek94.github.io/pocket-globe-app
MIT License
11 stars 2 forks source link

Fix flickering photos when changing theme #38

Closed sitek94 closed 4 years ago

sitek94 commented 4 years ago

When theme is changing the App component re-renders.

I was already using React.memo to prevent unnecessary re-renders of Photos component but it seems that something is not working as expected.

sitek94 commented 4 years ago

Solution I was passing down to Photos component an array with terms like so:

<Photos term={[term, 'trave']} columns={3} />

So I was creating a new array each time and Photos component was thinking that the props change all the time.