Coder Social home page Coder Social logo

zpao / react-devtools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebook/react-devtools

0.0 3.0 0.0 8.04 MB

React Developer Tools is a Chrome extension that allows you to inspect the React component hierarchy in the Chrome Developer Tools (formerly WebKit Web Inspector).

Home Page: https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi

License: Other

react-devtools's Introduction

React Developer Tools

React Developer Tools is a Chrome extension that allows you to inspect the React component hierarchy in the Chrome Developer Tools (formerly WebKit Web Inspector).

Installation

Easy

Install the extension from Chrome Web Store

If you inspect an element or launch the developer tools on a React page, you should see an extra tab called React in the inspector.

Hard

Clone the GitHub repository.

git clone [email protected]:facebook/react-devtools.git

Clone the blink submodule.

git submodule update --init

Open the URL chrome://extensions/ in your browser.

Check the box for Developer Mode

Click the button Load unpacked extension...

Select the folder where you downloaded the repository.

The extension is now installed.

The React Tab Doesn't Show Up?

The current version of React Developer Tools is not compatible with all build systems. It tries to load the React runtime by either detecting a global called React, or by calling require('React') or require('react') in the global scope. Your page needs to support this to be compatible with the Developer Tools.

You can test this on the React website or by inspecting Facebook.

The React Tab Is Blank?

Due to a bug in Chrome, devtools extensions are unable to use localStorage if the "Block third-party cookies and site data" option is checked in the Chrome content settings. Until this bug is fixed, please make sure this preference is unchecked.

Usage

You should have a new tab called React in your Chrome DevTools. This shows you the root React components that was rendered on the page, as well as the subcomponents that they ended up rendering.

By selecting one of the components in the tree you can inspect and edit its current props and state in the panel on the right. In the breadcrumbs you can inspect the selected Component, the Component that created it, the Component that created that one, and so on.

ProTips

If you inspect a React element on the page using the regular Elements tab, then switch over to the React tab, that element will be automatically selected in the React tree.

Similarly, if you have a breakpoint within the render phase of a Component, that will be automatically selected in the React tab. This allows you to step through the rendering tree and see how one Component affects another one.

By breaking on errors, you can easily find which component threw an error during rendering, and what props lead to it.

Contribute

Test Environment

Open the Chrome DevTools on any React page by inspecting an element.

In a different tab goto chrome://inspect/. Open the last section called Others. This contain your DevTools instance. Click the inspect link next to it. That should open up another DevTools instance, which is inspecting the first one, including the React extension. Inception.

If you don't have a simple React page available you can use the built-in test page. Open the URL chrome://extensions/ again. Look for the unique ID of the extension. E.g:

chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/tests/page.html

Project Structure

The purpose of this project is to trail the DevTools of the Chromium project. Therefore the project is structured similarly. For example this project doesn't use a module system. Each file is inserted using a script tag in the global scope of the page. Files are isolated by global namespaces.

Please read the Structure document for more information about the folder structure of the project.

More…

There's only so much we can cram in here. To read more about the community and guidelines for submitting pull requests, please read the Contributing document.

react-devtools's People

Contributors

jamesgpearce avatar jgebhardt avatar sanderspies avatar sebmarkbage avatar sgrove avatar sophiebits avatar

Watchers

 avatar  avatar  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.