Skip to content

Instantly share code, notes, and snippets.

@clintonmedbery
Last active January 3, 2020 20:10
Show Gist options
  • Save clintonmedbery/b311cee7145cb434e11176b80ee465f2 to your computer and use it in GitHub Desktop.
Save clintonmedbery/b311cee7145cb434e11176b80ee465f2 to your computer and use it in GitHub Desktop.
React Code Sample with hooks
import React, { useState, useEffect } from 'react'
const Thing = (props) => {
let [things, setThings] = useState([])
useEffect(() => {
}, [])
return (
<ThingView
things={things}
/>
)
}
export default Thing
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
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