Hey,
I need help with the Expense Tracker project.
I did all the steps, and when I got to the last one, where we are asked to write the transactionsSlice with createSlice function, I ran the code, nothing rendered and when looking at the console this is what I got:
Uncaught ReferenceError: transactionsReducer is not defined
at [email protected]/toolkit (index.compiled.js:712:16)
at o (index.compiled.js:1:265)
at index.compiled.js:1:316
at 14.../../components/TransactionForm (index.compiled.js:621:26)
at o (index.compiled.js:1:265)
at index.compiled.js:1:316
at 6.../features/budgets/Budgets (index.compiled.js:225:44)
at o (index.compiled.js:1:265)
at index.compiled.js:1:316
at 16../app/App (index.compiled.js:722:35)
I found that in the index.compiled.js on line 722, there is indeed a call to transactionReducer, which I removed since writing the reducer inside the createSlice method, and it seems to come from this line in the transactionsSlice file:
export const selectFlattenedTransactions = (state) => Object.values(state.transactions).reduce((a,b) => […a, …b], );
Anybody has a clue what is going on?
By the way, this is my code inside transactionSlice.js, if this helps…
const transactionsSlice = createSlice({
name: 'transactions',
initialState: initialState,
reducers: {
addTransaction: (state, action) => {
state[action.payload.category].push(action.payload);
},
deleteTransaction: (state,action) => {
state[action.payload.category].filter(obj => obj.id !== action.payload.id);
}
}
});
export const selectTransactions = (state) => state.transactions;
export const selectFlattenedTransactions = (state) => Object.values(state.transactions).reduce((a,b) => [...a, ...b], []);
export {addTransaction, deleteTransaction} = transactionsSlice.actions;
export default transactionsSlice.reducer;