Skip to content

Instantly share code, notes, and snippets.

@antklim
Created February 22, 2024 23:47
Show Gist options
  • Save antklim/a44f71142730bdac7e3c6ff53cb5df74 to your computer and use it in GitHub Desktop.
Save antklim/a44f71142730bdac7e3c6ff53cb5df74 to your computer and use it in GitHub Desktop.
type ReducerState = {
count: number;
};
type ReducerAction =
| {
type: "add";
add: number;
}
| {
type: "subtract";
subtract: number;
};
const reducer = (state: ReducerState, action: ReducerAction) => {
const reducer: Reducer<ReducerState, ReducerAction> = (state, action) => {
switch (action.type) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment