How to erase all the data from all different reducers when user log out in react native? -


i have 2 reducers 1 authentication , second fetching list of data. when log out app, authentication reducer gets reinitialize don't know how reinitialize second reducer @ time of logging out.

here combine reducers code:

export default combinereducers({     auth: authreducer,     patientreducer: patientreducer, }); 

then import reducers in app.js:

import reducers './reducers';   class app extends component {      render() {         const store = createstore(reducers,{},applymiddleware(reduxthunk));         return (             <provider store={store}>                 <routercomponent />             </provider>         );     } }  export default app; 

please tell me if how dispatch action of log out both of reducers reinitialize/empty.

because whenever log out , log in account app first renders previous user's data list because second reducer(patientreducer) doesn't reinitialize/empty @ time of logging out , re-renders data list of current logged in user.

you can have initial_state containing properties empty/null. when user signs out can call action sends type handled needed reducers. in reducers return ...initial_state.

just explain points: every time dispatch action, reducers receives dispatch. however, reducers handles same type returns code want to. since want clear many reducers, can share same type on of them, able handle single action dispatch.

hope helps.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -