use-strict-params
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

use-strict-params

Build status npm version

Strictly typed params for React router.

Installation

npm

npm install use-strict-params

Yarn

yarn add use-strict-params

pnpm

pnpm add use-strict-params

bun

bun add use-strict-params

Usage

useStrictParams

A typed variant of useParams. The following types are supported:

  • String
  • Number
  • Boolean
  • Date
const { userId } = useStrictParams({ userId: Number })

useStrictSearchParams

A typed variant of useSearchParams. The following types are supported:

  • String
  • Number
  • Boolean
  • Date
const { query } = useStrictSearchParams({ query: String })

Optional

Marks a type as optional which will change the return type to allow null.

const { query } = useStrictSearchParams({ query: Optional(String) })

Package Sidebar

Install

npm i use-strict-params

Weekly Downloads

27

Version

1.0.1

License

ISC

Unpacked Size

6.01 kB

Total Files

5

Last publish

Collaborators

  • mskelton