I am following a redux tutorial by dan abramov, the code is very simple:
import { schema, arrayOf } from 'normalizr';
export const todo = new schema.Entity('todos');
export const arrayOfTodos = arrayOf(todo);
but I have this error:
Uncaught TypeError: (0 , _normalizr.arrayOf) is not a function
This is how I am using it in my dispatch:
return api.fetchTodos(filter).then((response) => {
dispatch({
type: 'FETCH_TODOS_SUCCESS',
filter,
response: normalize(response, schema.arrayOfTodos),
});
}
I cannot seem to trace the error here, what's wrong with this code?
For the error try this:
import { schema } from 'normalizr';
export const todo = new schema.Entity('todos');
export const arrayOfTodos = schema.Array(todo);
Not sure about your version of normalizr but based on the docs there were some structural changes in the lib itself.