React第三方组件4(状态管理之Reflux的使用④TodoList下)

React第三方组件4(状态管理之Reflux的使用④TodoList下)_第1张图片
React第三方组件4(状态管理之Reflux的使用④TodoList下)_第2张图片

本教程总共5篇,每日更新一篇,请关注我们!你可以进入历史消息查看以往文章,也敬请期待我们的新文章!

1、React第三方组件4(状态管理之Reflux的使用①简单使用)---2018.03.13

2、React第三方组件4(状态管理之Reflux的使用②TodoList上)---2018.03.14

3、React第三方组件4(状态管理之Reflux的使用③TodoList中)---2018.03.15

4、React第三方组件4(状态管理之Reflux的使用④TodoList下)---2018.03.16

5、React第三方组件4(状态管理之Reflux的使用⑤异步操作)---2018.03.19

开发环境:Windows 8,node v8.9.1,npm 5.5.1,WebStorm 2017.2.2

1、我们先复制一份reflux3到reflux4

React第三方组件4(状态管理之Reflux的使用④TodoList下)_第3张图片

2、修改reflux下的Index.jsx文件

import Reactfrom 'react';

import {HashRouter, Route, NavLink, Redirect}from 'react-router-dom';

import ReFlux1from './reflux1/Index'

import ReFlux2from './reflux2/Index'

import ReFlux3from './reflux3/Index'

import ReFlux4from './reflux4/Index'

const Index = ({match}) =>

           

               ReFlux1

               ReFlux2

               ReFlux3

               ReFlux4


render={() => ()}/>

           

           

           

           

;

export default Index;

3、修改 reflux4下的Index.jsx

import Reactfrom 'react'

import Refluxfrom 'reflux'

import Actionfrom './Action'

import Storefrom './Store'

class Listextends Reflux.Component {

constructor(props) {

super(props);

       this.store = Store;

   }

render() {

let {list} =this.state;

       let type =this.props.type;

       let LiCont = ({data}) =>

  •                {data.title}

                       onClick={() => Action.itemEdit({

    id: data.id,

                           status: data.status ===1 ?0 :1

                       })}

    className={data.status ===1 ?"del" :"recovery"}>

                       {data.status ===1 ?"删除" :"恢复"}

           ;

           return (

                   {

    list.length >0 && list.map(data => [

    type ===0 ?

                                   :

    type ===1 && data.status ===1 ?

                                       :

    type ===2 && data.status ===0 ?

                                           :

    null

                           ]

    )

    }

           );

       }

    }

    class Indexextends Reflux.Component {

    render() {

    return (

                   

                    Action.addTodo(this.refs['todoInput'].value)}>添加

                   

                       

                           全部

                       

                           未删除

                       

                           已删除

           );

       }

    }

    export default Index;

    4、查看浏览器

    React第三方组件4(状态管理之Reflux的使用④TodoList下)_第4张图片

    本文完

    禁止擅自转载,如需转载请在公众号中留言联系我们!

    感谢童鞋们支持!

    如果你有什么问题,可以在下方留言给我们!

  • 你可能感兴趣的:(React第三方组件4(状态管理之Reflux的使用④TodoList下))