# use-child

> > React hook for getting the type of any nested child component

Latest version **1.0.0** (published 2022-06-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-child
pnpm add use-child
yarn add use-child
bun add use-child
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-06-17 |
| First published | 2022-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ozan Yurtsever |
| Maintainers | ozanyurtsever |

## Links

- npm: https://www.npmjs.com/package/use-child
- Repository: https://github.com/ozanyurtsever/use-child
- npm.io page: https://npm.io/package/use-child

## Recent versions

- 1.0.0 (latest) — 2022-06-17

## README

# `use-child`

> React hook for getting the type of any nested child component

## Install

```sh
npm install use-child
```

## Usage

```js
import useChild from 'use-child';

const Car = props => {
  const [wheelExists, WheelComponent] = useChild(props.children, Wheel);
  const [engineExists, EngineComponent] = useChild(props.children, Engine);

  return (
    <div>
      {wheelExists && WheelComponent}
      {engineExists && EngineComponent}
    </div>
  );
};

const Wheel = () => {
  return <div>I am a wheel</div>;
};

const Engine = () => {
  return <div>I am an engine</div>;
};
```

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