Need help with updating the state after adding inputVal. Currently, it only works on the first click and throws this error:
Error:
TypeError: Cannot add property 1, object is not extensible
import { createReducer, on } from '@ngrx/store'
import { addTodo } from '../actions/todo.actions'
export const initialState: any[] = []
let test: any[] = []
const _todoReducer = createReducer(
initialState,
on(addTodo, (state: any, { inputVal }) => {
test.push(inputVal)
state = test
return state
})
)
export function todoReducer(state, action) {
return _todoReducer(state, action)
}
Any suggestions on how to push or update state in NgRx? Or if not possible, what are some workarounds?