I have a a helper function that I call when I want to delete something from my redux store. However I need to be able to access the current store inside the function to make a determination on what to do next. Here's what I want to do:
export function deleteDocument (id) {
this.props.dispatch(deleteShape({id}));
const getStore = getStore(); //<-- I need something like this
if(getStore.documents && !getStore.documents.find(doc => doc.selected)){
this.props.dispatch(makeTopDocumentSelected());
}
}
I call this function from a component and pass the "this" context to it so it will have access to dispatch if you're curious about that. But if I try to reference a prop that I pass along it doesn't update after the "deleteShape" call because this function is not "connected" (for lack of a better word) to the redux store. So my question is this: how can I access the current redux store from non-component functions? Thanks