Question: Init function isn't calling when Reflux.createStore

Question

Init function isn't calling when Reflux.createStore

Answers 0
Added at 2016-07-19 13:07
Tags
Question

I have mocked store

var action = Reflux.createAction('action');
var mockFn = jest.genMockFn();

var store = Reflux.createStore({
    init: function () {
        console.log("INIT MOCK");
        this.listenTo(action, this.onAction);
    },
    onAction: function () {
        mockFn();
    }
});

export default store;

and when component try to listen the store

componentDidMount = () => {

  ...

  const deregStoreListener = ConceptStore.listen(
    ({nodes,centroids}) => {
      ...
    }
  )
}

it throw error

TypeError: _index2.default.listen is not a function

The strange behavior is that init function wasn't called. So Reflux.createStore didn't created store properly. Why?

Answers
Source Show
◀ Wstecz