This is being done so that we can embed DevTools within the new React (beta) docs. The primary changes here are to `react-devtools-inline/backend`: * Add a new `createBridge` API * Add an option to the `activate` method to support passing in the custom bridge object. The `react-devtools-inline` README has been updated to include these new methods. To verify these changes, this commit also updates the test shell to add a new entry-point for multiple DevTools. This commit also replaces two direct calls to `window.postMessage()` with `bridge.send()` (and adds the related Flow types).
20 lines
518 B
JavaScript
20 lines
518 B
JavaScript
import * as React from 'react';
|
|
import {useState} from 'react';
|
|
import {createRoot} from 'react-dom';
|
|
|
|
function createContainer() {
|
|
const container = document.createElement('div');
|
|
|
|
((document.body: any): HTMLBodyElement).appendChild(container);
|
|
|
|
return container;
|
|
}
|
|
|
|
function StatefulCounter() {
|
|
const [count, setCount] = useState(0);
|
|
const handleClick = () => setCount(count + 1);
|
|
return <button onClick={handleClick}>Count {count}</button>;
|
|
}
|
|
|
|
createRoot(createContainer()).render(<StatefulCounter />);
|