Skip to content

Instantly share code, notes, and snippets.

@Eyongkevin
Created June 17, 2020 18:42
Show Gist options
  • Save Eyongkevin/d9299a1cb7ba177c502565aea92f30b9 to your computer and use it in GitHub Desktop.
Save Eyongkevin/d9299a1cb7ba177c502565aea92f30b9 to your computer and use it in GitHub Desktop.
sample code for the tuts `Build a Shopping Cart with React, Redux, and React-DnD`
import React, { Component } from 'react';
import { connect } from 'react-redux'
import '../index.css'
import { _getPhones } from '../utils/_DATA'
import { receivePhones } from '../actions/phones'
import Container from './container'
class App extends Component {
componentDidMount(){
_getPhones()
.then((phones) =>{
this.props.dispatch(receivePhones(phones))
})
}
render(){
const { phones } = this.props
return (
<Container phones={phones} />
);
}
}
function mapStateToProps({phones}){
return{
phones
}
}
export default connect(mapStateToProps)(App);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment