File tree Expand file tree Collapse file tree 5 files changed +33
-28
lines changed Expand file tree Collapse file tree 5 files changed +33
-28
lines changed Original file line number Diff line number Diff line change @@ -9,21 +9,21 @@ import React from 'react'
99import PropTypes from 'prop-types'
1010import { connect } from 'react-redux'
1111
12- export const mapStateToProps = state => ({
13-
14- })
15-
16- export const mapDispatchToProps = {
17-
18- }
19-
2012export const ${ 1 :hocComponentName } = (WrappedComponent) => {
21- const hocComponent = ({ ... props } ) => <WrappedComponent {...props} />
13+ const hocComponent = (props) => <WrappedComponent {...props} />
2214
2315 hocComponent.propTypes = {
2416 }
2517
2618 return hocComponent
2719}
2820
21+ const mapStateToProps = (state, ownProps) => ({
22+
23+ })
24+
25+ const mapDispatchToProps = (dispatch, ownProps) => ({
26+
27+ })
28+
2929export default WrapperComponent => connect(mapStateToProps, mapDispatchToProps)(${ 1 :hocComponentName } (WrapperComponent))
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ export class ${1:${TM_FILENAME_BASE}} extends Component {
2323 }
2424}
2525
26- const mapStateToProps = (state) => ({
26+ const mapStateToProps = (state, ownProps ) => ({
2727
2828})
2929
30- const mapDispatchToProps = {
30+ const mapDispatchToProps = (dispatch, ownProps) => ( {
3131
32- }
32+ })
3333
3434export default connect(mapStateToProps, mapDispatchToProps)(${ 1 :${TM_FILENAME_BASE } })
Original file line number Diff line number Diff line change 55# key : reduxmap
66# --
77
8- const mapStateToProps = (state) => ({
9- ${1}
8+ const mapStateToProps = (state, ownProps) => ({
9+
10+ })
11+
12+ const mapDispatchToProps = (dispatch, ownProps) => ({
13+
1014})
1115
12- const mapDispatchToProps = {
13-
14- }
16+ const mergeProps = (stateProps, dispatchProps, ownProps) => ({
17+ ...ownProps,
18+ ...dispatchProps,
19+ ...stateProps,
20+ })
Original file line number Diff line number Diff line change @@ -18,18 +18,18 @@ export class ${1:${TM_FILENAME_BASE}} extends Component {
1818 render() {
1919 return (
2020 <View>
21- <Text> ${ 2 :textInComponent } </Text>
21+ <Text>${ 2 :textInComponent } </Text>
2222 </View>
2323 )
2424 }
2525}
2626
27- const mapStateToProps = (state) => ({
28-
27+ const mapStateToProps = (state, ownProps ) => ({
28+
2929})
3030
31- const mapDispatchToProps = {
32-
33- }
31+ const mapDispatchToProps = (dispatch, ownProps) => ( {
32+
33+ })
3434
3535export default connect(mapStateToProps, mapDispatchToProps)(${ 1 :${TM_FILENAME_BASE } })
Original file line number Diff line number Diff line change @@ -11,11 +11,10 @@ const initialState = {
1111
1212export default (state = initialState, { type, payload }) => {
1313 switch (type) {
14+ case ${ 1 :typeName } :
15+ return { ...state, ...payload }
1416
15- case ${ 1 :typeName } :
16- return { ...state, ...payload }
17-
18- default:
19- return state
17+ default:
18+ return state
2019 }
2120}
You can’t perform that action at this time.
0 commit comments