Is it possible to trigger a Redux action from outside a component? [duplicate]

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'));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)