Last active
January 3, 2020 20:10
-
-
Save clintonmedbery/b311cee7145cb434e11176b80ee465f2 to your computer and use it in GitHub Desktop.
React Code Sample with hooks
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, { useState, useEffect } from 'react' | |
const Thing = (props) => { | |
let [things, setThings] = useState([]) | |
useEffect(() => { | |
}, []) | |
return ( | |
<ThingView | |
things={things} | |
/> | |
) | |
} | |
export default Thing |
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 { connect } from 'react-redux' | |
import Thing from './ThingComponent' | |
import { actions } from '../../reducers/thing.reducer' | |
const mapStateToProps = (state) => ({ | |
things: state.page.things | |
}) | |
const mapDispatchToProps = (dispatch) => ({ | |
getThings: () => dispatch(actions.getThings()), | |
}) | |
const ThingContainer = connect(mapStateToProps, mapDispatchToProps)(Things) | |
export default ThingContainer |
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 from 'react' | |
import styles from './thing-styles.module.scss' | |
import PropTypes from 'prop-types' | |
const propTypes = { | |
count: PropTypes.number.isRequired | |
} | |
const defaultProps = { | |
count: 1 | |
} | |
const ThingView = ({ things }) => { | |
return ( | |
<> | |
</> | |
) | |
} | |
ThingView.propTypes = propTypes | |
ThingView.defaultProps = defaultProps | |
export default ThingView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment