Advertisement
Guest User

Untitled

a guest
Jan 25th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export const postsSlice = createSlice({
  2.     name: 'post',
  3.     initialState: {
  4.         lastID: 0,
  5.         posts: []
  6.     },
  7.     reducers: {
  8.         createPost: (state, action) => {
  9.             state.posts.push({
  10.                 id: ++state.lastID,
  11.                 author: action.payload.author,
  12.                 text: action.payload.text
  13.             });
  14.         }
  15.     }
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement