redux-saga-model-loading
redux-saga-model 的 loading 插件
install
$ npm i redux-saga-model-loading
or
$ yarn add redux-saga-model-loading
使用
index.js
import React from "react";import ReactDOM from "react-dom";import Provider from 'react-redux'import "antd/dist/antd.css"; import loading from 'redux-saga-model-loading';import sagaModel from "reudx-saga-model";import Layout from "./view/Layout.jsx";import UsersTable from "./view/UsersTable.jsx"; //加载插件sagaModel; ReactDOM;
component.js
import React from "react";import Table Input Icon Button Popconfirm from "antd";import connect from "react-redux";import bindActionCreators from "redux";import namespace as dbNamespace from "../../db/dataModel.js";import * as action from "../../action.js";const columns = //...; Component {} { thisprops; }; { const dataSourceloading = thisprops; const columns = thiscolumns; return <div> <Table = = =/> </div> ; } const mapDispatchToProps = { return ;}; const mapStateToProps = { const usersState = statedbNamespace; return dataSource: usersStatelist count: usersStatecount // 获取对应 namespace 下的 loading 状态 loading:stateloadingmodelsdbNamespace ;}; mapStateToProps mapDispatchToPropsEditableTable;
action.js
const getUsers = { return type:'users/db/getUsers' payload:{} //告诉插件为 users/db/getUsers 这个副作用开启 loading meta:META }