Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- state = {8xf0y6ziyjabvozdd253nd:[
- {
- "id": "894tuq4ut84ut8v4t8wun89g",
- "parentId": "8xf0y6ziyjabvozdd253nd",
- "timestamp": 1503045227866,
- "body": "Hi there! I ams a COMMENTSsg.",
- "author": "thingtwo",
- "voteScore": 143,
- "deleted": false,
- "parentDeleted": false
- },
- ]}
- let index = state[payload.id].findIndex((element)=> element.id === payload.data.id)
- return { ...state,
- [payload.id]:[...state[payload.id],index=payload.data]
- }
- {8xf0y6ziyjabvozdd253nd:[
- {
- "id": "894tuq4ut84ut8v4t8wun89g",
- "parentId": "8xf0y6ziyjabvozdd253nd",
- "timestamp": 1503045227866,
- "body": "Hi there! I am a COMMENTS.",
- "author": "thingtwo",
- "voteScore": 143,
- "deleted": false,
- "parentDeleted": false
- },
- {
- "id": "894tuq4ut84ut8v4t8wun89g",
- "parentId": "8xf0y6ziyjabvozdd253nd",
- "timestamp": 1503045227866,
- "body": "Hi there! I am a COMMENTS Replace",
- "author": "thingtwo",
- "voteScore": 143,
- "deleted": false,
- "parentDeleted": false
- }
- ]}
- {8xf0y6ziyjabvozdd253nd:[
- {
- "id": "894tuq4ut84ut8v4t8wun89g",
- "parentId": "8xf0y6ziyjabvozdd253nd",
- "timestamp": 1503045227866,
- "body": "Hi there! I am a COMMENTS Replace",
- "author": "thingtwo",
- "voteScore": 143,
- "deleted": false,
- "parentDeleted": false
- }
- ]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement