1

I am New to React Redux.This is a simple App I am developing.But Error is I can't connect to store through Action.

This is my error

utils.js:78 Uncaught Error: action is missing a listen method

topic-list.js

    var React = require('react');
var Reflux = require('reflux');
var TopicStore = require('../stores/topic-store');
var Actions = require('../actions');

module.exports = React.createClass({
    mixins:[
      Reflux.listenTo(TopicStore,'onChange')  
    ],
    getInitialState:function () {
      return{
          topics:[]
      }
    },
    componentWillMount:function () {
       //Actions.getTopics()
        Actions.getTopics()
    },
    render:function () {
      return <div className="list-group">
          ToPic List
          {this.renderTopics()}
      </div>
    },
    renderTopics:function () {

        return this.state.topics.map(function(topic) {
            return <li key={topic.id}>
                {topic.description}
            </li>

        })

    },
    onChange:function (evet,topics) {
        this.setState({topics:topics})
    }


});

actions.js

var Reflux = require('reflux');

module.exports = Reflux.createAction([
    'getTopics',

]);

topic-store.js

    var Api = require('../utils/api');
var Reflux = require('reflux');
var Actions = require('../actions');


module.exports = Reflux.createStore({
    listenables:[Actions],
   getTopics:function () {
       return Api.get('topics/defaults')
           .then(function (json) {
               this.topics = json.data;
               this.triggerChange();
           }.bind(this));
   },
    con:function () {
      console.log('Working')
    },
    triggerChange:function () {
        this.trigger('change',this.topics)

    }
});
Bajwa kapoor
  • 73
  • 3
  • 12

1 Answers1

0

The error message implies you are trying to listen to something which can't be listened to (ie. it doesn't have a listen method.)

That means the source of the error can either be:

  1. listenables:[Actions] from topic-store.js
  2. Reflux.listenTo(TopicStore,'onChange') from topic-list.js

I believe it's the former, as there is a typo in actions.js, as the method is Reflux.createActions, not Reflux.createAction.

caffeinated.tech
  • 6,428
  • 1
  • 21
  • 40