Is it possible to trigger a Redux action from outside a component?
In order to dispatch and action from outside of the scope of React.Component
you need to get the store instance and call dispatch
on it like
import { store } from '/path/to/createdStore';
function testAction(text) {
return {
type: 'TEST_ACTION',
text
}
}
store.dispatch(testAction('StackOverflow'));