# react-generic-functions

> React generic memo & forwardRef

Latest version **1.0.9** (published 2024-01-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-generic-functions
pnpm add react-generic-functions
yarn add react-generic-functions
bun add react-generic-functions
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2024-01-18 |
| First published | 2023-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 118.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fipnooone |
| Maintainers | fipnooone |
| Keywords | react, generic, memo, forwardRef |

## Links

- npm: https://www.npmjs.com/package/react-generic-functions
- Repository: https://github.com/fipnooone/react-generic-functions
- Issues: https://github.com/fipnooone/react-generic-functions/issues
- npm.io page: https://npm.io/package/react-generic-functions

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2024-01-18
- 1.0.8 — 2024-01-18
- 1.0.7 — 2024-01-18
- 1.0.6 — 2024-01-18
- 1.0.5 — 2023-12-13
- 1.0.4 — 2023-12-13
- 1.0.3 — 2023-12-13
- 1.0.2 — 2023-12-13
- 1.0.0 — 2023-12-13

## README

# react-generic-functions

Simple generic memo & forwardRef react functions

## Usage

```tsx
import { memo, forwardRef } from 'react-generic-funtions';

interface ExampleComponentProps<T> {
    genericProp: T
}

const ExampleComponent = forwardRef(
        <T extends string | number>({ genericProp }: ExampleComponentProps<T>,
        ref: ForwardedRef<HtmlDivElement>
    ) => {
        const message = useMemo(() => {
            if (typeof genericProp === 'number') {
                return 'hello';
            } else {
                return 'word';
            }
        }, [genericProp])

        return (
            <div ref={ref}>
                {message}
            </div>
        );
    }
);

import { useRef } from 'react';

const ExampleRoot: FC = () => {
    const componentRef = useRef<HtmlDivElement>(null);
    const [state, setState] = useState<string | number>(0)
    
    // ...

    return (
        <div>
            {/* ... */}
            <ExampleComponent genericComponent={state} ref={ref} />
            {/* ... */}
        </div>
    )
}

```

---
_Source: https://npm.io/package/react-generic-functions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
