spread state in react redux

i want to know is what ...state do? is it change value of the store to initial value or let store as latest value?

import * as actionType from "../actions/actionTypes";

const initialStore = {
  roomsCount: 0,
  resPerPage: 0,
  rooms: [],
  filteredRooms: 0,
  error: null,
  success: false,

const reducer = (state = initialStore, action) => {
  switch (action.type) {
    case actionType.ALL_ROOM_SUCCESS:
      return {
        rooms: action.rooms,
        roomsCount: action.roomsCount,
        resPerPage: action.resPerPage,
        filteredRooms: action.filteredRooms,
    case actionType.ALL_ROOM_FAILED:
      return {
        error: action.err,

if at first i use this reducer be success and of course error will be null and success will be true, but second time will be fail, and i used ...state.. on this situation what is the success value? is initial (false) or as first request (true)?

Read more here: https://stackoverflow.com/questions/68472520/spread-state-in-react-redux

Content Attribution

This content was originally published by Rawand122 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: