Open MrHazimAli opened 5 years ago
I'm having issues with the CLEAR_DATA action in componentWillUnmount of Component A route being called after GET_REQUEST actions in Component B route, causing the data in Component B to get cleared immediately after it's requested.
This is likely a problem with how I set up React Router, but I've had no luck fixing it. Being able to name what data to remove would solve this issue for me.
@prescottprue is there any workaround this?
My use-case is that I am using useFirestoreConnect({ collection: "todos", storeAs: "todo", doc: docId })
and I'd like to be able to clear state.firestore.data.todo
on unmount of a react component.
(if that helps you understand what I am trying to achieve in relation to this comment you made on a similar issue https://github.com/prescottprue/redux-firestore/issues/150#issuecomment-439690604)
Any way to manually enhance the reducer allowing it to handle an action and remove part of the firestore state?
Thanks
I've wanted this for a while. For now, I'm dispatching my own LISTENER_RESPONSE, e.g.:
type: '@@reduxFirestore/LISTENER_RESPONSE',
meta: {
collection: '<your collection>',
doc: '<doc id>',
storeAs: '<your redux path>'
},
payload: {
data: {},
},
this effectively replaces whatever you had in Redux before with an empty object.
What is the feature? As for now, we can dispatch
actionTypes.CLEAR_DATA
once user logout to clear all data inside firestore or preserve which collection inside firestore that we want to retain. but this feature request is focusing on removing specific tree via dispatch when user logout.What version would this apply to? latest
Do you have thoughts/examples on how the feature would be used (i.e. API)? probably something like this:-
dispatch({ type: actionTypes.CLEAR_DATA, forget: { data: ['todos'], ordered: ['todos'] } })