How to use the react-devtools-core.connectToDevTools function in react-devtools-core

To help you get started, we’ve selected a few react-devtools-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shirakaba / react-nativescript / sample / app / app.ts View on Github external
// };
// mySocket.onerror = function(ev: Event){
//     console.error("[SOCKET] Socket had an error", ev);
// };

/* https://github.com/facebook/react-devtools/issues/601#issuecomment-290611996
 * https://github.com/sidorares/react-x11/blob/master/src/DevToolsIntegration.js */
(global as any).__DEV__ = true;

// import * as React from "react";
// Object.defineProperty(window, 'React', {
//     value: React
// });

const {connectToDevTools} = require('react-devtools-core');
const wsInstance = connectToDevTools({
    host: 'localhost',
    port: 8097,
    /* This does NOT work */
    // websocket: (global as any).WebSocket,
    resolveRNStyle: null,
    isAppActive: () => true,
});

console.log(`[app.ts] Got wsInstance:`, wsInstance);
console.log(`[app.ts] wsInstance's onopen was:`, wsInstance.onopen);

(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__.on('react-devtools', (agent: any) => {
    console.log(`Got 'react-devtools' callback!`);
    // let highlightedNodes: any[] = [];
    // agent.on('highlight', data => {
    //     highlight(data.node, data.name);

react-devtools-core

Use react-devtools outside of the browser

MIT
Latest version published 10 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages