Simple Store with useState

In this lesson, we learn a different pattern with useState and custom hooks, create a store in a couple of lines, and also make use of Immer.

Initial state #

The initial state is the same as in the previous lessons.

const initialState = {
  todos: [
    { id: 1, title: 'Wash dishes' },
    { id: 2, title: 'Study JS' },
    { id: 3, title: 'Buy ticket' },
  ],
  query: '',
};

useValue #

The initial state is only needed for useState. ...