Question: Uncaught Error : Action is missing a listen method React/Reflux?

Question

Uncaught Error : Action is missing a listen method React/Reflux?

Answers 0
Added at 2016-08-25 15:08
Tags
Question

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)

    }
});
Answers
Source Show
◀ Wstecz