# cm-react-inspector

> 一款在基于build-scripts项目中使用的插件,在本地调试时，可以快速定位页面上的组件所在的源码的位置。

Latest version **0.1.2** (published 2021-05-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install cm-react-inspector
pnpm add cm-react-inspector
yarn add cm-react-inspector
bun add cm-react-inspector
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2021-05-16 |
| First published | 2021-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 90.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | wenjingyuer@126.com |
| Maintainers | wenjingyuer |
| Keywords | react, ice.js, ice plugin, component, inspector |

## Links

- npm: https://www.npmjs.com/package/cm-react-inspector
- Repository: https://github.com/CHOOSE6868/cm-react-inspector
- Homepage: https://github.com/CHOOSE6868/cm-react-inspector#readme
- Issues: https://github.com/CHOOSE6868/cm-react-inspector/issues
- npm.io page: https://npm.io/package/cm-react-inspector

## Dependencies (5)

- [react](https://npm.io/package/react.md) ^17.0.2
- [hotkeys-js](https://npm.io/package/hotkeys-js.md) ^3.8.5
- [loader-utils](https://npm.io/package/loader-utils.md) ^2.0.0
- [react-dev-utils](https://npm.io/package/react-dev-utils.md) ^11.0.4
- [react-reconciler](https://npm.io/package/react-reconciler.md) ^0.26.2

## 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

- 0.1.2 (latest) — 2021-05-16
- 0.1.1 — 2021-05-13
- 0.1.0 — 2021-05-13

## README

### cm-react-inspector

------

cm-react-inspector是一款build-script的插件,适合在基于build-script的项目中使用(如使用ice.js构建的项目)。用于在本地调试时，快速定位页面上的组件所在的源码的位置。

![演示](./images/show.gif)

本项目的开发基于:

[react-dev-inspector](https://github.com/zthxxx/react-dev-inspector)

[build-plugin-dev-inspector](https://ice.alibaba-inc.com/docs/guide/develop/plugin-list#build-plugin-dev-inspector)

如果需要在基于其他构建工具(umi、create-react-app等)的项目中使用,请使用
[react-dev-inspector](https://github.com/zthxxx/react-dev-inspector)

### 使用方式

1.安装

```
npm i --save-dev cm-react-inspector
```

2.在 `build.json` 中引入插件

```json
{
  "plugins": [
    "cm-react-inspector"
  ]
}
```

3.Add Inspector React Component

```javascript
import React from 'react'
import { Inspector, InspectParams } from 'react-dev-inspector'

const InspectorWrapper = process.env.NODE_ENV === 'development'
  ? Inspector
  : React.Fragment

export const Layout = () => {
  // ...

  return (
    <InspectorWrapper
      // props docs see:
      // https://github.com/zthxxx/react-dev-inspector#inspector-component-props
      keys={['shift', 'command', 'o']}
      disableLaunchEditor={false}
      onHoverElement={(params: InspectParams) => {}}
      onClickElement={(params: InspectParams) => {}}
    >
     <YourComponent>
       ...
     </YourComponent>
    </InspectorWrapper>
  )
}

```

### IDE / Editor config

#### VSCode

- install VSCode command line tools, [see the official docs](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line)
  ![install-vscode-cli](./images/install-vscode-cli.png)

- set env to shell, like `.bashrc` or `.zshrc`
  ```bash
  export REACT_EDITOR=code
  ```

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