Skip to content

Instantly share code, notes, and snippets.

@pfulop
Created August 30, 2016 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfulop/8d911217045faa2d89a9a25d433a01ac to your computer and use it in GitHub Desktop.
Save pfulop/8d911217045faa2d89a9a25d433a01ac to your computer and use it in GitHub Desktop.
//@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