zoukankan      html  css  js  c++  java
  • react-redux异步数据操作

    import React, { Component } from 'react';
    import './App.css';
    import {connect} from 'react-redux';
    import {bindActionCreators} from 'redux';
    import action from './react-redux/todos/action'
    // ui 组件 只取数据
    class App extends Component {
      constructor(props){
        super(props);
        this.add = this.add.bind(this)     
      };
      add(){
        this.props.ADD(this.node.value);
        this.node.value = '';
      };
      render() {
        console.log(this.props)
        return (
          <div className="App">
            <input type="text" ref={node=>this.node=node}/>
            <button onClick={this.add}>add</button>
            {this.props.todos.list.map((item,index)=>{
              return (
                  <div key={index}> 
                    {item}
                  </div>
              )
            })}
          </div>
        );
      }
    }
    let mapStateToProps = (state)=>state;
    // 将dispatch传进去省区了actions 里的方法去 触发action的内置对象
    let mapDispatchToProps = (dispatch)=>bindActionCreators(action,dispatch)
    //高阶组件 必须传组件进去 export
    default connect(mapStateToProps,mapDispatchToProps)(App);
  • 相关阅读:
    向IPython Notebook中导入.py文件
    python--时间日期
    python--条件和循环
    python--输入输出
    python--字符串
    python--内置函数
    python--异常
    python--模块
    python--数据结构
    pybrain
  • 原文地址:https://www.cnblogs.com/l8l8/p/9482754.html
Copyright © 2011-2022 走看看