1

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?

Rick Hanlon II
  • 20,549
  • 7
  • 47
  • 53
Gleb
  • 1,312
  • 3
  • 18
  • 36
  • Dont forget to import the store file. i think the store is not called. i was facing the same problem once. and its that my store file is never called. so i have imported it in my staring component and it was working. – Rafi Ud Daula Refat Aug 20 '16 at 14:35

0 Answers0