[x] Missing closing quotation mark for email: "justcallmehal@example.com,.
[x] Certain slices of state should hold reference to others. EX: When displaying an answer, we want to be able to quickly look up comments for that answer in order to display them. We don't want to iterate through all comments to find them, so instead we'll store an array of comment_ids inside of each answer. Now, we only need to iterate through that smaller subset, and utilize the fast lookup of objects to extract the comments from the comments slice of state. Here's what that may look like:
answers: {
11: {
id: 11,
answerer_id: 2,
question_id: 101,
accepted: true,
body: "test test test test test test ",
comment_ids: [1, 2],
created_at: "Aug 26 '09 at 16:15",
updated_at: "Oct 2 '18 at 0:38"
},
12: {
id: 12,
answerer_id: 3,
question_id: 101,
accepted: false,
body: "test test test test test test ",
comment_ids: [],
created_at: "Aug 26 '09 at 16:15",
updated_at: "Oct 2 '18 at 0:38"
}
},
comments: {
1: {
id: 1,
commentable_id: 11,
commentable_type: "ANSWER",
commenter_id: 2,
body: "I am answering you",
updated_at: "Mar 4 '10 at 21:54"
},
2: {
id: 2,
commentable_id: 11,
commentable_type: "ANSWER",
commenter_id: 3,
body: "Changing the default after so many years ? Too late for that : it would break so many existing sites/scripts/applications... The only possible thing is to help make things better, for the future.",
updated_at: "Mar 4 '10 at 21:54"
}
},
[x] Missing closing quotation mark for
email: "justcallmehal@example.com,
.[x] Certain slices of state should hold reference to others. EX: When displaying an answer, we want to be able to quickly look up comments for that answer in order to display them. We don't want to iterate through all comments to find them, so instead we'll store an array of
comment_ids
inside of each answer. Now, we only need to iterate through that smaller subset, and utilize the fast lookup of objects to extract the comments from thecomments
slice of state. Here's what that may look like: