plotly.js 1.57.0/1.56.0 and react-plotly.js 2.5.0 are not said to be incompatible
This combination of plotly.js and react-plotly.js seems to be unsupported. I might try with other versions in future too. It would be useful to write about this in some file if it is confirmed.
TypeError Cannot read property 'document' of undefined
Code Sandbox
https://codesandbox.io/s/nervous-elbakyan-x3i8e?file=/src/App.js
Screenshot

Updates
plotly.js 1.56.0 has a similar error:

Thank you.
I am not sure if the title of this issue is correct. After posting the above, I tested locally in another separate project and the versions look compatible. Maybe it is an issue in CodeSandbox, or in other places too. I don't know.
Are things working in this same environment with previous versions i.e. 1.55 ? I don't think we broke anything here.
It is not working with 1.55 in CodeSandbox: https://codesandbox.io/s/trusting-jepsen-j4cvi?file=/package.json.

plotly.js npm page says to install it with "plotly.js-dist". The readme here says to install "plotly.js"
I tried upgrading to 2.51 and plotly.js-dist to 1.58.4 but all sorts of errors appear. Adding plotly.js as another dependency gave me "d3 is not defined".