Skip to content

Commit

Permalink
Step 8. 通过dva-loading 处理loading 状态
Browse files Browse the repository at this point in the history
  • Loading branch information
JobbyM committed Apr 26, 2017
1 parent 404d040 commit 0fdc60d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"antd": "^2.9.3",
"babel-runtime": "^6.9.2",
"dva": "^1.2.1",
"dva-loading": "^0.2.1",
"react": "^15.4.0",
"react-dom": "^15.4.0"
},
Expand Down
14 changes: 0 additions & 14 deletions src/components/Example.js

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/Users/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Table, Pagination, Popconfirm } from 'antd';
import styles from './Users.css';
import { PAGE_SIZE } from '../../constants';

function Users({ list: dataSource, total, page: current }) {
function Users({ list: dataSource, loading, total, page: current }) {
function deleteHandler(id){
console.warn(`TODO: ${id}`);
}
Expand Down Expand Up @@ -46,6 +46,7 @@ function Users({ list: dataSource, total, page: current }) {
<Table
columns={columns}
dataSource={dataSource}
loading={loading}
rowKey={record => record.id}
pagination={false}
/>
Expand All @@ -63,6 +64,7 @@ function Users({ list: dataSource, total, page: current }) {
function mapStateToProps(state){
const { list, total, page } = state.users
return {
loading: state.loading.models.users,
list,
total,
page,
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import dva from 'dva';
import createLoading from 'dva-loading';
import './index.css';

// 1. Initialize
const app = dva();

app.model(require("./models/users"));

// 2. Plugins
// app.use({});
app.use(createLoading());

// 3. Model
// app.model(require('./models/example'));
app.model(require('./models/users'));

// 4. Router
app.router(require('./router'));
Expand Down

0 comments on commit 0fdc60d

Please sign in to comment.