Skip to content

Commit 8900bff

Browse files
author
Henrik Lissner
authored
Merge pull request #26 from sei40kr/redux-snippets
Add flux/redux snippets to +web-react-mode
2 parents 3475c15 + 3286d88 commit 8900bff

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

+web-react-mode/action

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- mode: snippet -*-
2+
# contributor: Seong Yong-ju
3+
# name: action
4+
# key: action
5+
# --
6+
const ${1:$(upcase (s-snake-case yas-text))} = '${1:$(upcase (s-snake-case yas-text))}';
7+
8+
export const ${1:actionName} = (${2:args}) => ({
9+
type: '${1:$(upcase (s-snake-case yas-text))}',
10+
payload: {
11+
$0
12+
},
13+
});

+web-react-mode/container

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- mode: snippet -*-
2+
# contributor: Seong Yong-ju
3+
# name: Redux container
4+
# key: container
5+
# --
6+
import { connect } from 'react-redux';
7+
8+
const mapStateToProps = (state, ownProps) => ({
9+
$0
10+
});
11+
12+
const mapDispatchToProps = (dispatch, ownProps) => ({
13+
14+
});
15+
16+
const ${1:`(f-base buffer-file-name)`} = connect(
17+
mapStateToProps,
18+
mapDispatchToProps
19+
)(${2:Component});
20+
21+
export default $1;

+web-react-mode/mergeProps

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- mode: snippet -*-
2+
# contributor: Seong Yong-ju
3+
# name: mergeProps
4+
# key: mergeProps
5+
# --
6+
const mergeProps = (stateProps, dispatchProps, ownProps) => ({
7+
...stateProps,
8+
...dispatchProps,
9+
...ownProps,
10+
$0
11+
});

+web-react-mode/reducer

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- mode: snippet -*-
2+
# contributor: Seong Yong-ju
3+
# name: reducer
4+
# key: reducer
5+
# --
6+
const initialState = {
7+
$1
8+
};
9+
10+
export default (state = initialState, action) => {
11+
switch (action.type) {
12+
$0
13+
14+
default:
15+
return state;
16+
}
17+
};

0 commit comments

Comments
 (0)