Package Exports
- react-devtools-inline
- react-devtools-inline/backend
- react-devtools-inline/frontend
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-devtools-inline) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-devtools-inline
React DevTools implementation for embedding within a browser-based IDE (e.g. CodeSandbox, StackBlitz).
This is a low-level package. If you're looking for the standalone DevTools app, use the react-devtools package instead.
Usage
This package exports two entry points: a frontend (to be run in the main window) and a backend (to be installed and run within an iframe1).
The frontend and backend can be initialized in any order, but the backend must not be activated until after the frontend has been initialized. Because of this, the simplest sequence is:
- Frontend (DevTools interface) initialized in the main
window. - Backend initialized in an
iframe. - Backend activated.
1 Sandboxed iframes are supported.
API
react-devtools-inline/backend
initialize- Installs the global hook on the window. This hook is how React and DevTools communicate. This method must be called before React is loaded! (This means before anyimportorrequirestatements.)activate- Lets the backend know when the frontend is ready. It should not be called until after the frontend has been initialized, else the frontend might miss important tree-initialiation events.
import { activate, initialize } from 'react-devtools-inline/backend';
// Call this before importing React (or any other packages that might import React)
initialize();
// Call this only once the frontend has been initialized
activate();react-devtools-inline/frontend
initialize- Configures the DevTools interface to listen to a targetiframe. This method returns a React element that can be rendered directly.
import { initialize } from 'react-devtools-inline/frontend';
// This should be the iframe the backend hook has been installed in.
const iframe = document.getElementById(frameID);
// This returns a React component that can be rendered into your app.
// <DevTools {...props} />
const DevTools = initialize(iframe);