SolidJSS
SolidJSโ€ข4y agoโ€ข
7 replies
Mr Void

modify state by `produce` vs directly

what is the difference between:
const addTodo = (text) => {
    setTodos([...todos, { id: ++todoId, text, completed: false }]);
}

and
const addTodo = (text) => {
    setTodos(
        produce((todos) => {
            todos.push({ id: ++todoId, text, completed: false });
        })
     );
};


edit:

Immer inspired API for Solid's Store objects that allows for localized mutation.
what's a localized mutation?
Was this page helpful?