I have a actions.js file that is exporting actions like this
export var toggleTodo = (id) => {
return {
type: 'TOGGLE_TODO',
id
}
}
but when i import it using es6 import i get error
Uncaught TypeError: Cannot read property 'toggleTodo' of undefined
but when i require it using common js require it works just fine! Can someone explain to me why is this happening, I mean i read these two are same things... Something seem to be different ?
// var actions = require('actions') working
// dispatch(actions.toggleTodo(id));
import actions from 'actions' //not working
dispatch(actions.toggleTodo(id));