I have a react website which reads data from a source file (stored in /public) and displays it in an iframe. This data is changed by an external flask server when certain events are fired from my page. My problem is that when this file is changed, the entire page reloads, which breaks some functionality. I tried doing npm run build
and serving the build, but then the iframe doesn't update at all when it's changed. Is there any way to have the iframe refresh without letting the page refresh?
Asked
Active
Viewed 85 times
0

Alec
- 8,529
- 8
- 37
- 63
-
You've introduced a lot of pieces and perhaps not all are relevant. Is the issue [how to refresh an iframe](https://stackoverflow.com/questions/86428/what-s-the-best-way-to-reload-refresh-an-iframe)? or is it how to refresh a component in react (hint: setState) or is this a continuous development workflow issue with `npm run build`? Or does it have something to do with flask? I think your question needs some focus. – Wyck Jun 14 '22 at 19:29
-
Im afraid that this is overengineered. If you have something in public folder and it changes, then development server will detect the change and rerender, this behaviour is intended. Once its built, thats different story. – Damian Busz Jun 14 '22 at 19:42
-
@DamianBusz is there any way to stop changes in public from refreshing the whole page but still allow iframe source file to update so that iframe updates? – Alec Jun 14 '22 at 20:55
-
Only other solution i can think of is sending the file as an event rather than writing to it but it's a pretty massive file and it seems like a waste of resources when i could just write to the file – Alec Jun 14 '22 at 20:56
-
@Alec The question is what are you trying to achieve. Why having the file in public folder if you use iframe to view it in first place? (unless I missundrstood) – Damian Busz Jun 14 '22 at 22:11
-
I guess my design pattern is bad. user records smth front-end, it's sent to backend flask, backend flask updates the file in public for front-end. I'll just use events i guess – Alec Jun 14 '22 at 22:19