git ssb

1+

dinoworm ๐Ÿ› / catstack



Commit 76f81afa54247dc961664e888a428d28dbffb096

render the todos yo!

Michael Williams committed on 1/8/2016, 6:05:34 AM
Parent: c89794caeffafc465f3dd30e6a332ec2581775ec

Files changed

app/todos/routes.jschanged
app/todos/container.jsdeleted
app/todos/components/todo-list.jsadded
app/todos/components/todo.jsadded
app/todos/containers/index.jsadded
app/todos/routes.jsView
@@ -1,6 +1,8 @@
11 import React from 'react'
2-import { Route } from 'react-router'
2+import { Route, IndexRoute } from 'react-router'
33
4-import TodosContainer from './container'
4+import IndexContainer from './containers/index'
55
6-export default <Route path="todos" component={TodosContainer} />
6+export default <Route path="todos">
7+ <IndexRoute component={IndexContainer} />
8+</Route>
app/todos/container.jsView
@@ -1,20 +1,0 @@
1-import React from 'react'
2-import { connect } from 'react-redux'
3-
4-import actions from './actions'
5-
6-class TodosContainer extends React.Component {
7- static fetchData = (getState, dispatch, location, params) => {
8- return dispatch(actions.find())
9- }
10-
11- render () {
12- return <div>
13- todo list!
14- </div>
15- }
16-}
17-
18-export default connect(
19- (state) => ({})
20-)(TodosContainer)
app/todos/components/todo-list.jsView
@@ -1,0 +1,13 @@
1+import React from 'react'
2+
3+export default class TodoList extends React.Component {
4+ render () {
5+ return <ul>
6+ {
7+ React.Children.map(this.props.children, todo => {
8+ return <li>{ todo }</li>
9+ })
10+ }
11+ </ul>
12+ }
13+}
app/todos/components/todo.jsView
@@ -1,0 +1,9 @@
1+import React from 'react'
2+
3+export default class Todo extends React.Component {
4+ render () {
5+ return <div>
6+ { this.props.todo.text }
7+ </div>
8+ }
9+}
app/todos/containers/index.jsView
@@ -1,0 +1,29 @@
1+import React from 'react'
2+import { connect } from 'react-redux'
3+import { map, values } from 'ramda'
4+
5+import actions from '../actions'
6+import TodoList from '../components/todo-list'
7+import Todo from '../components/todo'
8+
9+class TodosContainer extends React.Component {
10+ static fetchData = (getState, dispatch, location, params) => {
11+ return dispatch(actions.find())
12+ }
13+
14+ render () {
15+ return <TodoList>
16+ {
17+ values(map(todo => {
18+ return <Todo todo={todo} />
19+ }, this.props.todos))
20+ }
21+ </TodoList>
22+ }
23+}
24+
25+export default connect(
26+ (state) => ({
27+ todos: state.todos.records
28+ })
29+)(TodosContainer)

Built with git-ssb-web