Download dev.to-clone/src/store/comment/currentComments.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/dev.to-clone/src/store/comment/currentComments.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/dev.to-clone/src/store/comment/currentComments.js
-
curl -L -o currentComments.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/dev.to-clone/src/store/comment/currentComments.js
1.17 kB
| import { createSlice } from '@reduxjs/toolkit'; | |
| import { getItemFromLocalStorage } from '../../helper/localStorage'; | |
| const initialState = { | |
| currentComments: [], // when giving like to multiple comment items quickly , it takes a time to transform comment item with already liked or not , so I stored transformed current comments in redux store and put them to server | |
| commentItem: getItemFromLocalStorage('commentItemToManage') || null, // to manage => edit || delete | |
| transformedComments: getItemFromLocalStorage('transformedComments') || [], // for deleting comment | |
| }; | |
| const currentCommentsSlice = createSlice({ | |
| name: 'currentComment', | |
| initialState, | |
| reducers: { | |
| setCurrentComments: (state, action) => { | |
| state.currentComments = action.payload; | |
| }, | |
| setcommentItem: (state, action) => { | |
| state.commentItem = action.payload; | |
| }, | |
| setTransformedComments: (state, action) => { | |
| state.transformedComments = action.payload; | |
| }, | |
| }, | |
| }); | |
| export const { setCurrentComments, setcommentItem, setTransformedComments } = | |
| currentCommentsSlice.actions; | |
| export default currentCommentsSlice.reducer; | |