# react-docgen-imports-handler

> A handler for react-docgen that finds the names of all imported modules.

Latest version **1.0.0** (published 2016-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-docgen-imports-handler
pnpm add react-docgen-imports-handler
yarn add react-docgen-imports-handler
bun add react-docgen-imports-handler
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-08-14 |
| First published | 2016-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | nerdlabs |
| Maintainers | nerdlabs |
| Keywords | react, documentation-generation, react-docgen |

## Links

- npm: https://www.npmjs.com/package/react-docgen-imports-handler
- Repository: https://github.com/nerdlabs/react-docgen-imports-handler
- Homepage: https://github.com/nerdlabs/react-docgen-imports-handler#readme
- Issues: https://github.com/nerdlabs/react-docgen-imports-handler/issues
- npm.io page: https://npm.io/package/react-docgen-imports-handler

## Dependencies (1)

- [recast](https://npm.io/package/recast.md) 0.11.11

## 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.0 (latest) — 2016-08-14

## README

# react-docgen-imports-handler [![Build Status](https://travis-ci.org/nerdlabs/react-docgen-imports-handler.svg?branch=master)](https://travis-ci.org/nerdlabs/react-docgen-imports-handler)
A handler for react-docgen that finds the names of all imported modules.

## Rationale
[react-docgen](https://github.com/reactjs/react-docgen) is a CLI and API toolbox
to help extract information from [React](http://facebook.github.io/react/)
components and generate documentation from it.

`react-docgen-imports-handler` is a custom handler for `react-docgen` and can be
used to extract a list of all the module dependencies for a given component.

In its current state it only extracts the name of the module / file, but ideas
for a future version include to also extract the exported names (e.g. is it a
`default` export? is it a `named` export? which names are being imported?).

## Installation
Install `react-docgen-imports-handler` from [npm](https://www.npmjs.com/package/react-docgen-imports-handler)

```shell
npm install --save react-docgen-imports-handler
```

## Usage
Unfortunately there is currently no easy way to use custom handlers with the
[react-docgen CLI](https://github.com/reactjs/react-docgen#cli).

Discussions and Ideas about how to make this easier are happening in the
[react-docgen issue discussions](https://github.com/reactjs/react-docgen/issues/115).

If you want to use this module programmatically check out the [react-docgen API docs](https://github.com/reactjs/react-docgen#api) for more information about
the `react-docgen` API.  
Below is a small example that demonstrates how to
integrate `react-docgen-imports-handler`.

```javascript
import reactDocs from 'react-docgen';
import importsHandler from 'react-docgen-imports-handler';
const resolver = reactDocs.resolver.findExportedComponentDefinition;
const handlers = reactDocs.handlers.concat(importsHandler);
const documentation = reactDocs.parse(src, resolver, handlers);
```

## Examples
When using this custom handler with `react-docgen` it will find the names of
every `import`ed or `require()`ed file and add them to the resulting
documentation.

```javascript
import React from 'react';
import MyButton from '../mybutton';
export default function MyComponent() { return <MyButton />; }
```

```json
{
  "imports": ["react", "../mybutton"],
  "props": {...}
}
```

For more information about the data format see the [react-docgen readme](https://github.com/reactjs/react-docgen#result-data-structure)

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