Code Monkey home page Code Monkey logo

preact-devtools's Introduction

Preact Devtools

Browser extension that allows you to inspect a Preact component hierarchy, including props and state.

⚠️ Requires Preact >=10.1.0 ⚠️

Screenshot of Preact devtools

Usage

Firstly, we need to import preact/debug somewhere to initialize the connection to the extension. Make sure that this import is the first import in your whole app.

// Must be the first import
import "preact/debug";

Then, download the Preact Devtools extension for your browser:

Contributing

  • Use npm run dev to start a demo page
  • Use npm run watch to rebuild all extensions on any code changes
  • Use npm run build:firefox or npm run build:chrome to create a release build

Chrome:

  1. Go to extensions page
  2. Enable developer mode
  3. Click "Load unpacked"
  4. Select dist/chrome/ folder

Firefox:

  1. Go to addons page
  2. Click the settings icon
  3. Select "Debug addons"
  4. Click "Load temporary addon"
  5. Select the manifest.json in dist/firefox/

Embedding devtools directly into a page (highly experimental)

preact-devtools supports an inline build target, where the devtools can be embedded into any page without any restrictions like rendering it into iframes. Don't forget to include the css file too.

import "preact-devtools/dist/preact-devtools.css";
import { attach, createRenderer, renderDevtools } from "preact-devtools";
import { options } from "preact";

// Instantiate devtools backend and attach it to preact
// - store -> The backing store for the devtools
// - destroy -> unlisten and restore previous `preact.options`
const { store, destroy } = attach(options, createRenderer);

// Render the actual devtools into the specified DOM node
renderDevtools(store, document.getElementById("devtools"));

preact-devtools's People

Contributors

andrewiggins avatar marvinhagemeister avatar sean0x42 avatar yu-kgr avatar

Watchers

 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.