Elius94 / react-photo-sphere-viewer

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

Support React 18 Strict Mode #21

Closed alexjball closed 1 year ago

alexjball commented 1 year ago

fixes #20

In strict mode, react 18 runs effects twice before updating useState state, which was causing the viewer initialization to happen twice. storing the instance in a ref fixes this by updating the reference immediately inside the useEffect.

As far as I know the instance doesn't need to be reactive so useState is unnecessary.

Elius94 commented 1 year ago

Thank you @alexjball for your contribution 🗡️

Your commits are now included in the new release v3.2.0-psv5.0.2