Created
August 30, 2016 13:16
-
-
Save pfulop/8d911217045faa2d89a9a25d433a01ac to your computer and use it in GitHub Desktop.
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
//@flow | |
import React, { Component } from 'react'; | |
import { | |
Text, | |
View | |
} from 'react-native'; | |
import {pushItem,removeItem,updateItem,watchItems,unWatchItems} from '../actions/items'; | |
import {connect} from 'react-redux'; | |
import AddItem from './AddItem'; | |
import Items from './Items'; | |
class TheCall extends Component { | |
componentDidMount(){ | |
this.props.watchItems(); | |
} | |
componentWillUnmount(){ | |
this.props.unWatchItems(); | |
} | |
render() { | |
return ( | |
<View> | |
<AddItem pushItem={this.props.pushItem}/> | |
<Items items={this.props.items} removeItem={this.props.removeItem} updateItem={this.props.updateItem}/> | |
</View> | |
); | |
} | |
} | |
const mapStateToProps = ({items})=>{ | |
return {items}; | |
} | |
const mapDispatchToProps = (dispatch) => { | |
return { | |
pushItem: (item)=>dispatch(pushItem(item)), | |
removeItem: (_key)=>dispatch(removeItem(_key)), | |
updateItem: (_key,item)=>dispatch(updateItem(_key,item)), | |
watchItems: ()=>dispatch(watchItems()), | |
unWatchItems: ()=>dispatch(unWatchItems()) | |
} | |
} | |
export default | |
connect(mapStateToProps,mapDispatchToProps) (TheCall) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment