As soon as I use dispatch to change a property of the object in redux state, suddenly the whole component re-mounts in react native. Below is a part of my Slice.tsx:
const initialState = { LocalStorageInfoInitialState: { "IsLoggedIn": false, "IsFirstLaunch": true, "StatsEnabled": true, "Schedule_Walkthrough_Completed": false, "Statistics_Walkthrough_Completed": false } as LocalStorageInfoDataType, StudentInfoInitialState: {} as StudentInfoDataType, ScheduleArrayInitialState: [] as ScheduleArrayItem[], ExistingSubjectsArrayInitialState: [] as ExistingSubjectsArrayItem[], StudentsDataArrayInitialState:[] as StudentsDataArrayType[] } export const LocalStorageInfoSlice = createSlice({ name: 'LocalStorageInfo', initialState, reducers: { updateLocalStorageInfo: (state, action) = { if (action.payload == "Login") { state.LocalStorageInfoInitialState["IsLoggedIn"] = true } else if (action.payload == "Logout") { state.LocalStorageInfoInitialState["IsLoggedIn"] = false } else if (action.payload == "FirstLaunch") { state.LocalStorageInfoInitialState["IsFirstLaunch"] = false } else if (action.payload == "EnableStats") { state.LocalStorageInfoInitialState["StatsEnabled"] = true } else if (action.payload == "DisableStats") { state.LocalStorageInfoInitialState["StatsEnabled"] = false } else if (action.payload == "Schedule_Walkthrough_Completed") { state.LocalStorageInfoInitialState["Schedule_Walkthrough_Completed"] = true } else if (action.payload == "Statistics_Walkthrough_Completed") { state.LocalStorageInfoInitialState["Statistics_Walkthrough_Completed"] = true } } } }) Surprisingly, when I use dispatch to make changes in ScheduleArrayInitialState, ExistingSubjectsArrayInitialState and StudentsDataArrayInitialState which are an array as a whole in which I just push the value, everything works fine. But when I make changes in the objects of LocalStorageInfoInitialState and StudentInfoInitialState, it just re-mounts un-necessarily.
Please help me fix this problem. I am stuck with it for past 6 months with no solution.