I'm trying to understand why the main JS file is having trouble importing todo
from './actions'
without brackets, while there are no issues with importing todos
from './reducers'
.
Main js-file:
import { createStore } from 'redux'
import todo from './actions'
import todos from './reducers'
let store = createStore(todos);
store.dispatch(todo('Testing Redux!'));
console.log(store.getState());
My action file:
export const ADD_TODO = 'ADD_TODO';
function todo(text) {
return {type: ADD_TODO, text}
}
export default todo
My reducer file:
import { ADD_TODO } from './actions'
function todos(state = {}, action) {
switch(action.type) {
case ADD_TODO:
return [
...state,
{
text: action.text
}
]
default:
return state
}
}
export default todos