React third-party component 6 (use of Mobx for state management ⑤ asynchronous operation)

React third-party component 6 (use of Mobx for state management ⑤ asynchronous operation)

This tutorial has a total of 5 articles, one updated daily, please follow us! You can enter the historical news to view the previous articles, and stay tuned for our new articles!

1. React third-party components 6 (the use of Mobx for state management①simple use) ---2018.03.28

2. React third-party component 6 (Use of Mobx for state management ②TodoList) ---2018.03.29

3. React third-party component 6 (use of Mobx for state management ③TodoList) ---2018.03.30

4. React third-party component 6 (use of Mobx for state management ④under TodoList) ---2018.04.02

5. React third-party components 6 (use of Mobx for state management ⑤ asynchronous operation) ---2018.04.03

Development environment: Windows 8, node v8.9.1, npm 5.5.1, WebStorm 2017.2.2

1. We copy a copy of mobx4 to mobx5, and modify the Index.jsx file under mobx

2. Modify State.js

import apiRequestAsync from'../../../../public/js/apiRequestAsync';
@action postList = async() => {
    let todoList = await apiRequestAsync.post('todoList');
    runInAction(() => {
        this.list = todoList.list;
    })
};

3. Modify Index.jsx file

componentDidMount() {
    newState.postList()
}

4. View the browser

Reference: https://cloud.tencent.com/developer/article/1092684 React third-party component 6 (use of Mobx for state management ⑤ asynchronous operation)-Cloud + Community-Tencent Cloud