Solve the cache problem of ant-design refresh

1. When using ant-design-mobilethe ListViewcomponents, the problem I encountered was that the page data was not completely refreshed and emptied when the pull refresh was performed, so I encountered a series of problems.
2. At this time, I thought of finding a way to force a page refresh or a way to Reactre-render, but react-appthere are some peculiarities when used , so the above two methods did not work. Instead, it will cause the problem of refreshing the blank login on the app.
3, because based dva.jsdevelopment, the conceivable method is to directly in another modeldata synchronization processing, a method to define the data to be processed can be emptied.

Code example

  • In modelthe corresponding definition of a data processing method for emptying
    clearData(state) {
    
    
      return {
    
    
        ...state,
        data: [],  // 数据清空
        dataSource: dataUtils.getListViewDataSource(),
        pagination: {
    
     ...networkUtils.pagination },
      };
    },

  • Just call it synchronously in the corresponding place of the component.
   dispatch({
    
    
              type: 'createDynamics/clearData'
            })

In this way, it is very simple to solve the various problems that the data is not cleared.

Guess you like

Origin blog.csdn.net/weixin_45416217/article/details/109128576