codesandbox-client
codesandbox-client copied to clipboard
App Only Works After Code Is Changed
Hello, I played around with the @use-gesture/react and react-spring libraries and this very simple example from their docs sometimes just doesn't work in CSB. Not sure if it's an issue with the libraries or with the CSB client, but the weird thing is that just commenting out (or uncommenting) a console log statement or something else unrelated to the app makes it work. Somehow CSB doesn't do a full refresh when the code is changed, and this partial refresh seems to make it work while a full refresh doesn't:
https://codesandbox.io/s/dreamy-grass-v1j9fz?file=/src/App.js
There is a console log statement in line 16, at least in my browser (Chrome 101.0.4951.26 on ChromeOS 14588.41.0), the app never works on first load (i.e. you can't drag the square) but it works after commenting out the statement or putting in another unrelated statement.
Hey @fweth - This is expected behaviour with Vanilla templates, it's due to a race condition with our HTML hydration logic and that script.
We're aware of it and it's on our to fix list, but not a priority at the moment I'm afraid.
For the moment, if you refresh the preview window rather than the full page once your code changes are saved it should be reflected.