为什么在回流店里没看到动静?
Why is the store did not see action in reflux?
我收到以下错误
actions.toggleMenu is not a function
我创建一个动作
module.exports = Reflux.createAction([
'callAi',
'logout',
'fullScreen',
'toggleMenu',
'showSidebar'
]);
我创建了这家商店
actions = require('../actions/menu.js');
module.exports = Reflux.createStore({
listenables: actions,
init: function () {
console.log('init', this) // Its good!
},
onCallAi: function () {},
onLogout: function () {},
onFullScreen: function () {},
onToggleMenu: function () {
console.log('actions onToggle', 'inMoment') //Not good
},
onShowSidebar: function () {}
});
而这个观点
actions = require('../../../../Plus-WRIO-App/js/actions/menu')
store = require('../../../../Plus-WRIO-App/js/stores/menu')
var CreateDomLeft = React.createClass({
mixins: [Reflux.listenTo(store, "log")],
toggle: function(){
console.log('toggle', 'GO');
actions.toggleMenu() // error here!!!
},
render: function() {
return (
<li onClick={this.toggle} className='btn btn-link'></li>
);
}
});
module.exports = CreateDomLeft;
你打错了。应该是createActions
(复数)
我收到以下错误
actions.toggleMenu is not a function
我创建一个动作
module.exports = Reflux.createAction([
'callAi',
'logout',
'fullScreen',
'toggleMenu',
'showSidebar'
]);
我创建了这家商店
actions = require('../actions/menu.js');
module.exports = Reflux.createStore({
listenables: actions,
init: function () {
console.log('init', this) // Its good!
},
onCallAi: function () {},
onLogout: function () {},
onFullScreen: function () {},
onToggleMenu: function () {
console.log('actions onToggle', 'inMoment') //Not good
},
onShowSidebar: function () {}
});
而这个观点
actions = require('../../../../Plus-WRIO-App/js/actions/menu') store = require('../../../../Plus-WRIO-App/js/stores/menu')
var CreateDomLeft = React.createClass({
mixins: [Reflux.listenTo(store, "log")],
toggle: function(){
console.log('toggle', 'GO');
actions.toggleMenu() // error here!!!
},
render: function() {
return (
<li onClick={this.toggle} className='btn btn-link'></li>
);
}
});
module.exports = CreateDomLeft;
你打错了。应该是createActions
(复数)