Skip to content

Commit 85b9bd2

Browse files
committed
deconstrucing state to props
1 parent 60a314f commit 85b9bd2

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/components/Categories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ const mapDispatchToProps = dispatch => {
4444
}
4545
};
4646
};
47-
function mapStateToProps(state) {
47+
function mapStateToProps({ categories }) {
4848
return {
49-
categories: state.categories
49+
categories
5050
};
5151
}
5252
export default connect(

src/components/CreatePost.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const mapDispatchToProps = dispatch => {
131131
}
132132
};
133133
};
134-
function mapStateToProps({ posts }, { categories }) {
134+
function mapStateToProps({ posts, categories }) {
135135
return {
136136
posts,
137137
categories

src/components/Post.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const mapDispatchToProps = dispatch => {
4444
dispatchCastVote: payload => dispatch(castVote(payload))
4545
};
4646
};
47-
function mapStateToProps({ posts }, { loading }) {
47+
function mapStateToProps({ posts, loading }) {
4848
return {
4949
posts,
5050
loading

src/components/PostDetail.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ class PostDetail extends Component {
5454
}
5555
}
5656

57-
function mapStateToProps(state) {
57+
function mapStateToProps({ posts, post, loading, comments }) {
5858
return {
59-
posts: state.posts,
60-
post: state.post,
61-
loading: state.loading,
62-
comments: state.comments
59+
posts,
60+
post,
61+
loading,
62+
comments
6363
};
6464
}
6565

0 commit comments

Comments
 (0)