Elius94 / react-photo-sphere-viewer

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

[Support]: Problem in changing the src prop between renders #28

Closed tomyitav closed 1 year ago

tomyitav commented 1 year ago

What are you trying to do?

Hi, thanks for this great project! it seems like changing the src property does not reload the 360 image.

<ReactPhotoSphereViewer
        src={url}
        height={"100vh"}
        width={"100%"}
        littlePlanet={false}
      ></ReactPhotoSphereViewer>

Code

No response

Sandbox Link

https://codesandbox.io/s/sandbox-react-photo-sphere-viewer-by-elius94-j064sm?file=/src/App.js

Library Version

Latest

What operating system are you using?

macOS

What browser are you using?

Chrome

Logs

No response

mkubdev commented 1 year ago

Hi @tomyitav, Yes, the src attribute will not re-render the panorama on state change.

You should use the setPanorama(path: string, options?: object) function (with useEffect() on router change, or from a button onClick() for eg) to change the panorama source.

Elius94 commented 1 year ago

@mkubdev Thanks man for helping answering this issue 🙏