forked from berwin/learn-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
76 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import * as types from '../constants/CategoryTypes'; | ||
|
||
// export add | ||
export function addCategory(name) { | ||
return { | ||
type: types.ADD_CATEGORY, | ||
name | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { Component } from 'react'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import * as actions from '../../actions/category.js'; | ||
|
||
export default class Category extends Component { | ||
render () { | ||
console.log('category-index.jsx', this.props) | ||
return (<div>menu</div>); | ||
} | ||
} | ||
|
||
let mapStateToProps = state => state; | ||
|
||
let mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Category); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,18 @@ | ||
import React, { Component } from 'react'; | ||
import { Link } from 'react-router'; | ||
import { connect } from 'react-redux'; | ||
import { bindActionCreators } from 'redux'; | ||
import * as actions from '../actions' | ||
import Category from './category/index.jsx'; | ||
import List from './list/index.jsx'; | ||
|
||
export default class Index extends Component { | ||
render () { | ||
console.log(this.props) | ||
return ( | ||
<div> | ||
<h1>Todo-List</h1> | ||
<div className="box"> | ||
<div>menu</div> | ||
<div>list</div> | ||
<Category /> | ||
<List /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
|
||
let mapStateToProps = state => state; | ||
|
||
let mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Index); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { Component } from 'react'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import * as actions from '../../actions/list.js'; | ||
|
||
export default class List extends Component { | ||
render () { | ||
console.log('list-index.jsx', this.props) | ||
return ( | ||
<div>list</div> | ||
); | ||
} | ||
} | ||
|
||
let mapStateToProps = state => state; | ||
|
||
let mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(List); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ADD_CATEGORY } from '../constants/CategoryTypes'; | ||
|
||
|
||
/** | ||
* 创建分类 | ||
* | ||
* | ||
*/ | ||
let createCategory = name => { | ||
let time = Date.now(); | ||
|
||
return { | ||
id: Math.random().toString(36).split('.').join(''), | ||
addTime: time, | ||
updateTime: time, | ||
name | ||
} | ||
} | ||
|
||
export default (state = [], action) => { | ||
switch (action.type) { | ||
case ADD_CATEGORY: | ||
return [createCategory(action.name)] | ||
|
||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { combineReducers } from 'redux'; | ||
import category from './category'; | ||
import list from './list'; | ||
|
||
export default combineReducers({list}); | ||
export default combineReducers({category, list}); |