Skip to content

Commit 64e9256

Browse files
committed
Updated props to have comments top level prop
Now, the server responds: { comments: [ c1, c2, etc.] } Before the props were just: [c1, c2, etc.]
1 parent 31bf155 commit 64e9256

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Specify the partial, as well as the name of the variable used in the partial
2-
json.array! @comments, { partial: "comments/comment", as: :comment }
2+
json.comments(@comments, partial: "comments/comment", as: :comment)

client/app/bundles/comments/actions/commentsActionCreators.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export function setIsSaving() {
1313
};
1414
}
1515

16-
export function fetchCommentsSuccess(comments) {
16+
export function fetchCommentsSuccess(data) {
1717
return {
1818
type: actionTypes.FETCH_COMMENTS_SUCCESS,
19-
comments,
19+
comments: data.comments,
2020
};
2121
}
2222

client/app/bundles/comments/components/SimpleCommentScreen/SimpleCommentScreen.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class SimpleCommentScreen extends BaseComponent {
3030
return (
3131
request
3232
.get('comments.json', { responseType: 'json' })
33-
.then(res => this.setState({ $$comments: Immutable.fromJS(res.data) }))
33+
.then(res => this.setState({ $$comments: Immutable.fromJS(res.data.comments) }))
3434
.catch(error => this.setState({ fetchCommentsError: error }))
3535
);
3636
}

client/app/bundles/comments/store/commentsStore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import reducers from '../reducers';
55
import { initalStates } from '../reducers';
66

77
export default props => {
8-
const initialComments = props;
8+
const initialComments = props.comments;
99
const { $$commentsState } = initalStates;
1010
const initialState = {
1111
$$commentsStore: $$commentsState.merge({

client/app/bundles/comments/store/routerCommentsStore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { routerReducer } from 'react-router-redux';
66
import { initalStates } from '../reducers';
77

88
export default props => {
9-
const initialComments = props;
9+
const initialComments = props.comments;
1010
const { $$commentsState } = initalStates;
1111
const initialState = {
1212
$$commentsStore: $$commentsState.merge({

0 commit comments

Comments
 (0)