React Utility
Installation
shell
$ npm install @biruni/reactshell
$ yarn add @biruni/reactshell
$ pnpm add @biruni/reactUsage As Hook
- Import
typescript
import { useStore } from '@biruni/react';- Use
tsx
const MyComponent = () => {
const store = useStore(MyStore);
};Use As Props Mapper
- Import
typescript
import { withStore, type WithStore } from '@biruni/react';- Define
update Props from:
typescript
type Props = {
myPropKey: string;
};to:
typescript
type Props = WithStore<
typeof MyStore,
{
myPropKey: string;
}
>;- Wrap
typescript
const NewMyComponent = withStore(MyStore, MyComponent);IMPORTANT
The mapped props will be read-only props and Immutable