I want access to the store (to the dispatch and observe) without the usage of React Components. I've been looking for a couple of hours, with no result.
This is the case. I've created the store in the App root:
import { Provider } from 'react-redux'
import createStore from './state/store';
let store = createStore();
ReactDOM.render(
<Provider store={store}>
<App>
</Provider>,
document.getElementById('root')
);
I'm happy using the connect function offered from react-redux when I need to add actions or listen to state changes in a component, but when I want to set some logics outside the component (mainly dispatch) i get stuck.
In short, I want to validate one field. I want to make a validation.js file where I can listen for changes from the store, run the validation logics, and then dispatch an action with the eventual error.
As far as the store, it is not global and I'm not using a React Component. Which is the way to get the store to listen for changes and to dispatch actions?
Thanks in advance.