0

I want to update the store with an action fired from a function in a helper class.

How can I bind and fire that action if my class is not a component?

A solution I have seen is to use a renderless component which returns null in its render() function. That way you can bind your actions to it. But this seems like a hackey solution and it would cause an unpleasant refactor of my helper class.

Oatmeal
  • 39
  • 4
  • You could import the store directly, and pass your action to its `dispatch` method. – djfdev May 18 '18 at 22:41
  • @djfdev Would that ensure that that store is the one the rest of the app is using and not a copy or something else? – Oatmeal May 18 '18 at 22:47
  • Correct. Here's a possible duplicate of your question with a lot of discussion https://stackoverflow.com/questions/38460949/what-is-the-best-way-to-access-redux-store-outside-a-react-component – djfdev May 18 '18 at 22:51

0 Answers0