import { createSlice , PayloadAction } from '@reduxjs/toolkit' ; import generateCleanComponentAtomTree from '../../utils/cleanComponentAtomTree' ; const initialState = { snapshotHistory : [ ] , renderIndex : 0 , cleanComponentAtomTree : { } , } ; export const snapshotSlice = createSlice ( { name : 'snapshotHistory' , initialState , reducers : { setSnapshotHistory : ( state , action ) => { state . snapshotHistory . push ( action . payload ) ; } , setRenderIndex : ( state , action ) => { state . renderIndex = action . payload ; } , setCleanComponentAtomTree : ( state , action ) => { state . cleanComponentAtomTree = generateCleanComponentAtomTree ( action . payload ) ; } , } , } ) ; export const { setSnapshotHistory , setRenderIndex , setCleanComponentAtomTree , } = snapshotSlice . actions ; export default snapshotSlice . reducer ;