GithubHelp home page GithubHelp logo

luckylin87 / react-dev-inspector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zthxxx/react-dev-inspector

0.0 0.0 0.0 8.48 MB

Home Page: https://react-dev-inspector.zthxxx.me

License: MIT License

TypeScript 100.00%

react-dev-inspector's Introduction

React Dev Inspector

dev-tool for inspect react components and jump to local IDE for component code.

NPM Version NPM Downloads Node.js License

Preview

Online demo: https://react-dev-inspector.zthxxx.me

Screen record (gif 8M):

inspector-gif

Install

npm i -D react-dev-inspector

Usage & Config

Use in React

import React from 'react'
import { Inspector } from 'react-dev-inspector'

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

export const Layout = () => { 
  // ...
  
  return (
    <InspectorWrapper
      keys={['control', 'shift', 'command', 'c']} // default keys
      ...  // Props see below
    >
     <XXXContent>
     </XXXContent>
    </InspectorWrapper>
  )
}

after <Inspector> component was mounted,you can use window.__REACT_DEV_INSPECTOR_TOGGLE__() to toggle inspector.

<Inspector> Component Props

typescript define you can see in react-dev-inspector/es/Inspector.d.ts

Property Description Type Default
keys inspector toggle hotkeys

supported keys see: https://github.com/jaywcjlove/hotkeys#supported-keys
string[] ['control', 'shift', 'command', 'c']
disableLaunchEditor whether disable click react component to open IDE for view component code

(launchEditor by default only support be used with react-dev-inpector plugins in dev)
boolean false
onHoverElement trigged while inpector start and mouse hover in a HTMLElement type ElementHandler -
onClickElement trigged while inpector start and mouse click on a HTMLElement type ElementHandler -

Plugin for umi3

// .umirc.dev.ts

// https://umijs.org/config/
import { defineConfig } from 'umi'

export default defineConfig({
  plugins: [
    'react-dev-inspector/plugins/umi/react-inspector',
  ],
  inspectorConfig: {
    exclude: [
      'xxx-file-will-be-exclude',
    ], 
  },
})

Plugin for manual used in webpack

import { inspectorChainWebpack } from 'react-dev-inspector/plugins/webpack/config-inspector'


inspectorChainWebpack(webpackConfigChain, { exclude: ['xxx-file'] })

Example Project Code

code see: https://github.com/zthxxx/react-dev-inspector/tree/master/site

project preview: https://react-dev-inspector.zthxxx.me

License

MIT LICENSE

react-dev-inspector's People

Contributors

zthxxx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.