Elius94 / react-photo-sphere-viewer

Photosphere Viewer for React.JS
MIT License
65 stars 21 forks source link

imperative handle: less re-creating and better typing #38

Closed PaleHazy closed 11 months ago

PaleHazy commented 11 months ago

This pull request enhances efficiency by memoizing the options object derived from the props, ensuring its recreation occurs only when specific props change. Additionally, it establishes a state for the HTML element, maintaining its persistence through subsequent renders. This strategy addresses a previously encountered issue where the handle was unnecessarily regenerated in each render cycle.

In my scenario, the objective is to integrate the API into my application's state, enabling its accessibility from multiple locations. However, caution is paramount to avoid rendering the component containing ReactPhotoSphereViewer, as doing so could initiate an endless setting loop if the handle's setting triggers a render.

As a temporary solution within my application, I encapsulated the component in a new one and applied memoization using a custom equality function. With this update, the focus shifts to simply memoizing the actual props being passed into the library.

this update would let me memoize the props themselves.

Elius94 commented 11 months ago

Hey! Thanks a lot for your helpful contribution ☺️ I Will do a Quick test this monday and then i'll merge. Let's keep in contact 🙏

Il sab 18 nov 2023, 19:33 Austin Palazzesi @.***> ha scritto:

This pull request enhances efficiency by memoizing the options object derived from the props, ensuring its recreation occurs only when specific props change. Additionally, it establishes a state for the HTML element, maintaining its persistence through subsequent renders. This strategy addresses a previously encountered issue where the handle was unnecessarily regenerated in each render cycle.

In my scenario, the objective is to integrate the API into my application's state, enabling its accessibility from multiple locations. However, caution is paramount to avoid rendering the component containing ReactPhotoSphereViewer, as doing so could initiate an endless setting loop if the handle's setting triggers a render.

As a temporary solution within my application, I encapsulated the component in a new one and applied memoization using a custom equality function. With this update, the focus shifts to simply memoizing the actual props being passed into the library.

this update would let me memoize the props themselves.

You can view, comment on, or merge this pull request online at:

https://github.com/Elius94/react-photo-sphere-viewer/pull/38 Commit Summary

File Changes

(1 file https://github.com/Elius94/react-photo-sphere-viewer/pull/38/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/Elius94/react-photo-sphere-viewer/pull/38, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRXUU6J27KLSBL4A36E6A3YFD5PDAVCNFSM6AAAAAA7RESFVKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYDANJTGAZTCOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>