fix(gatsby-image): fix memory leak and use more appropriate data structures for cache and listeners (#10278)
fix(gatsby-image): fix memory leak and use more appropriate data structures for cache and listeners (#10278)

* fix(gatsby-image): fix memory leak and use more appropriate data structures for cache and listeners

* fix(gatsby-image): remove from listeners when unmounting

* fix(gatsby-image): fix ref reference for fixed images

* nits

* Revert propType changes

* Fix issues after merge

* Fix cache bug after merge

* set -> add

* Cleanup observer on unmount

* remove → delete

* remove refs


Co-authored-by: Ward Peeters <f7d6f8166205aa91930091f422c0634df8a7ceb4@coding-tech.com>
gatsbyjs/gatsby,gatsbyjs/gatsby,ChristopherBiscardi/gatsby,ChristopherBiscardi/gatsby,gatsbyjs/gatsby,gatsbyjs/gatsby,ChristopherBiscardi/gatsby,gatsbyjs/gatsby,gatsbyjs/gatsby,ChristopherBiscardi/gatsby