How to force update Single Page Application (SPA) pages?

前端 未结 6 1843
生来不讨喜
生来不讨喜 2020-12-12 15:13

In fully server side based rendering (non Web 2.0), deploying server side code would directly update client side pages upon page reload. In contrast, in React based Single P

6条回答
  •  旧巷少年郎
    2020-12-12 15:31

    Yes in server side rendering if you need to update a small part of the page also you need to reload whole page. But in SPAs you update your stuffs using ajax, hence no need to reload the page. Seeing your problem I have some assumptions:

    You see one of your component got updated but other components getting data from same API didn't update. Here comes Flux Architecture. where you have your data in store and your component listen to store's changes, whenever data in your store changes all your components listening to it's change will be updated (no scene of caching).

    Or

    You need to control your component to be updated automatically. For that

    1. You can request your server for data in specific intervals
    2. Websockets can help you updating component data from server.

提交回复
热议问题