medhira-react-typescript-hooks
v0.1.0
Published
Custom React hooks for faster development - Powered by MEDHIRA
Maintainers
Readme
Why this package?
| Benefit | Description |
|--------|-------------|
| Typed updates | patchState is typed as Partial<S> for your state shape |
| Simple API | One hook for object state — no boilerplate reducers in your app |
| Tree-shakeable | sideEffects: false, dual ESM/CJS builds |
| React 18+ | Peer dependency on React 18 or 19 |
| Zero runtime deps | Only react is required at runtime |
Installation
npm install medhira-react-typescript-hooks reactyarn add medhira-react-typescript-hooks reactpnpm add medhira-react-typescript-hooks reactQuick Start
import { useDefaultReducer } from 'medhira-react-typescript-hooks';
type LoginState = {
email: string;
password: string;
};
const initialState: LoginState = { email: '', password: '' };
function LoginForm() {
const { state, patchState } = useDefaultReducer(initialState);
return (
<>
<input
value={state.email}
onChange={(e) => patchState({ email: e.target.value })}
/>
<input
type="password"
value={state.password}
onChange={(e) => patchState({ password: e.target.value })}
/>
</>
);
}Hooks
| Hook | Purpose |
|------|---------|
| useDefaultReducer | Object state with shallow patchState updates |
Architecture
flowchart TB
subgraph consumer["Your component"]
INIT["initialState: S"]
PATCH["patchState(Partial<S>)"]
end
subgraph hook["useDefaultReducer"]
UR["useReducer"]
end
subgraph internal["Internal — not part of public API"]
RED["patch reducer"]
end
INIT --> UR
PATCH --> UR
UR --> RED
RED -->|"next state"| consumerPublished entry point: medhira-react-typescript-hooks only. Do not import from dist/internal paths.
API snapshot
const { state, patchState, multipleAction } = useDefaultReducer(initialState);state— current state (S)patchState(patch)— shallow-mergepatchintostate(recommended)multipleAction— alias ofpatchState(deprecated)
Contributing
Contributions are welcome. See Contributing in the docs.
git clone https://github.com/HELLOMEDHIRA/medhira-react-typescript-hooks.git
cd medhira-react-typescript-hooks
npm install
npm test
npm run buildSponsor & support
- GitHub: HELLOMEDHIRA
- Email: [email protected]
- Docs: medhira-react-typescript-hooks.readthedocs.io
About MEDHIRA
MEDHIRA — Engineering Intelligence Across Everything
License
Made with passion by MEDHIRA.
