Public
Edited
Feb 2, 2024
Insert cell
Insert cell
Insert cell
{
const baseState = {
foo: "bar",
list: [{ text: "coding" }]
};

const state = mutative.create(
baseState,
(draft) => {
draft.list.push({ text: "learning" });
},
{ enablePatches: false, mark: mutative.markSimpleObject }
);

baseState.foo = "baz";
baseState.list[0].text = "programming";

return state;
}
Insert cell
Insert cell
{
immer.setAutoFreeze(false);

const baseState = {
foo: "bar",
list: [{ text: "coding" }]
};

const state = immer.produce(baseState, (draft) => {
draft.list.push({ text: "learning" });
});

baseState.foo = "baz";
baseState.list[0].text = "programming";

return state;
}
Insert cell
Insert cell
{
const baseState = valtio.proxy({
foo: "bar",
list: [{ text: "coding" }]
});

const state = valtio.proxy({
value: baseState
});
state.value.list.push({ text: "learning" });

baseState.foo = "baz";
baseState.list[0].text = "programming";

return state.value;
}
Insert cell
Insert cell
{
const baseState = {
foo: "bar",
list: [{ text: "coding" }]
};

const state = {
...baseState,
list: [...baseState.list, { text: "learning" }]
};

baseState.foo = "baz";
baseState.list[0].text = "programming";

return state;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more