init
This commit is contained in:
29
snippets/rjsx-mode/Redux/hocredux
Normal file
29
snippets/rjsx-mode/Redux/hocredux
Normal file
@@ -0,0 +1,29 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: 68de6229-17f5-4bd6-83ef-feaa3a1ccb31
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: hocComponentWithRedux
|
||||
# key: hocredux
|
||||
# --
|
||||
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
export const ${1:hocComponentName} = (WrappedComponent) => {
|
||||
const hocComponent = (props) => <WrappedComponent {...props} />
|
||||
|
||||
hocComponent.propTypes = {
|
||||
}
|
||||
|
||||
return hocComponent
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
export default WrapperComponent => connect(mapStateToProps, mapDispatchToProps)(${1:hocComponentName}(WrapperComponent))
|
||||
34
snippets/rjsx-mode/Redux/rcredux
Normal file
34
snippets/rjsx-mode/Redux/rcredux
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: c948b832-8ff1-41b2-a256-ce629dcd4dbe
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: reactClassCompomentRedux
|
||||
# key: rcredux
|
||||
# --
|
||||
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component {
|
||||
static propTypes = {
|
||||
${2:prop}: ${3:PropTypes}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
$0
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)($1)
|
||||
8
snippets/rjsx-mode/Redux/redux
Normal file
8
snippets/rjsx-mode/Redux/redux
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: ebcbdf19-4ba9-404f-ab66-eb9b992d7126
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: import redux statement
|
||||
# key: redux
|
||||
# --
|
||||
|
||||
import { connect } from 'react-redux'
|
||||
20
snippets/rjsx-mode/Redux/reduxmap
Normal file
20
snippets/rjsx-mode/Redux/reduxmap
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: 32f4d017-7d51-4d41-a954-91e2eaf493c5
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: mappingToProps
|
||||
# key: reduxmap
|
||||
# --
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
const mergeProps = (stateProps, dispatchProps, ownProps) => ({
|
||||
...ownProps,
|
||||
...dispatchProps,
|
||||
...stateProps,
|
||||
})
|
||||
35
snippets/rjsx-mode/Redux/rncredux
Normal file
35
snippets/rjsx-mode/Redux/rncredux
Normal file
@@ -0,0 +1,35 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: 73a39297-05ec-45c0-9a05-9b3e5653c477
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: reactNativeClassComponentRedux
|
||||
# key: rncredux
|
||||
# --
|
||||
|
||||
import React, { Component } from 'react'
|
||||
import { View, Text } from 'react-native'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
export class ${1:`(yas-jsx-get-class-name-by-file-name)`} extends Component {
|
||||
static propTypes = {
|
||||
${2:prop}: ${3:PropTypes}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<Text>${2:textInComponent}</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({
|
||||
|
||||
})
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)($1)
|
||||
11
snippets/rjsx-mode/Redux/rxaction
Normal file
11
snippets/rjsx-mode/Redux/rxaction
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: 9a5dfef3-2b52-4c8e-bad1-3493599e10d9
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: reduxAction
|
||||
# key: rxaction
|
||||
# --
|
||||
|
||||
export const ${1:actionName} = (payload) => ({
|
||||
type: ${1:$((yas-snake-case yas-text))},
|
||||
payload
|
||||
})
|
||||
8
snippets/rjsx-mode/Redux/rxconst
Normal file
8
snippets/rjsx-mode/Redux/rxconst
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: a274faf6-2964-4a22-adf7-1715d3b4a153
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: reduxConst
|
||||
# key: rxconst
|
||||
# --
|
||||
|
||||
export const ${1:constantName} = '${1:constantName}'
|
||||
20
snippets/rjsx-mode/Redux/rxreducer
Normal file
20
snippets/rjsx-mode/Redux/rxreducer
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: a7bb3ea0-bf96-401b-851e-a63b254f42ba
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: reduxReducer
|
||||
# key: rxreducer
|
||||
# --
|
||||
|
||||
const initialState = {
|
||||
|
||||
}
|
||||
|
||||
export default (state = initialState, { type, payload }) => {
|
||||
switch (type) {
|
||||
case ${1:typeName}:
|
||||
return { ...state, ...payload }
|
||||
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
10
snippets/rjsx-mode/Redux/rxselect
Normal file
10
snippets/rjsx-mode/Redux/rxselect
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# uuid: a654de53-26a1-4694-9da7-cc4b906d50fa
|
||||
# contributor: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
|
||||
# name: reduxSelector
|
||||
# key: rxselect
|
||||
# --
|
||||
|
||||
import { createSelector } from 'reselect'
|
||||
|
||||
export const ${1:selectorName} = state => state.${2:selector}
|
||||
Reference in New Issue
Block a user