Created
June 17, 2020 18:42
-
-
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`
This file contains hidden or 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
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