Skip to content

Quick Start

1. Install

npm install medhira-react-typescript-hooks react

2. Use in a component

import { useDefaultReducer } from 'medhira-react-typescript-hooks';

type ProfileState = {
  name: string;
  email: string;
};

const initialState: ProfileState = { name: '', email: '' };

function ProfileForm() {
  const { state, patchState } = useDefaultReducer(initialState);

  return (
    <>
      <input
        value={state.name}
        onChange={(e) => patchState({ name: e.target.value })}
      />
      <input
        value={state.email}
        onChange={(e) => patchState({ email: e.target.value })}
      />
    </>
  );
}

3. Next steps