0

I am using redux, react-redux and redux thunk for store management in my react native project, there is deferent reducers and actions. How I reset the entire store during logout

Is there any methods like createStore() to destroy a store? please share possible solutions

Thanks

jamal
  • 1,007
  • 1
  • 11
  • 26
  • You can create reducers what are restores the initial state, or if u are storing your state on AynscStorage and you can clear the state with key: persist:root. – Dániel Boros Jun 25 '21 at 08:14
  • Did you try to, well, refresh the page? – kunquan Jun 25 '21 at 08:16
  • @kunquan yes tried,if call the api again then reseting the value but , if I am not calling api then I am getting the previous user data, I want to destroy the store during logout – jamal Jun 25 '21 at 08:38
  • 3
    Does this answer your question? [How to reset the state of a Redux store?](https://stackoverflow.com/questions/35622588/how-to-reset-the-state-of-a-redux-store) – taguenizy Jun 25 '21 at 08:48

1 Answers1

1

The below solution worked for me,

import reduxReset from 'redux-reset'

const enHanceCreateStore = compose(
    applyMiddleware(thunk),
    reduxReset()  
  )(createStore)

const store = enHanceCreateStore(reducers)

dispatch reset action

store.dispatch({
  type: 'RESET'
})
jamal
  • 1,007
  • 1
  • 11
  • 26