Last active: 2 years ago
export default function App() {
const [user, setUser] = useReducer(
(state: User, newState: Partial<User>) => ({ ...state, ...newState }),
defaultUser
);
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<div>
<span>Update name: </span>
<input
type="text"
value={user.name}
onChange={(e) => setUser({ name: e.target.value })}
/>
</div>
<pre>{JSON.stringify(user, null, 2)}</pre>
</div>
);
}