question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support React Dev Tools

See original GitHub issue

Hello,

Adding the following in the mount function allows the React Dev Tools to work inside the iframe:

     <script>
      if (window.parent !== window) {
          window['__REACT_DEVTOOLS_GLOBAL_HOOK__'] = window.parent['__REACT_DEVTOOLS_GLOBAL_HOOK__'];
      }
     </script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.2.0/umd/react.development.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.2.0/umd/react-dom.development.js"></script>

Perhaps it’s useful for more people to have it by default.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
brian-manncommented, Mar 3, 2018

Instead of saying window.parent !== window you should probably just write… if (window.Cypress) { }

1reaction
NoriStecommented, Jul 16, 2019

@technomage I’ve just checked the @pedroteixeira solution and it works perfectly! I tried it in my own project and in a fresh create-react-app installation, everything works.

For the React DevTools, I’ve added

<script>
  if (window.Cypress) {
    window["__REACT_DEVTOOLS_GLOBAL_HOOK__"] = window.parent["__REACT_DEVTOOLS_GLOBAL_HOOK__"];
  }
</script>

before che </head> of the public/index.html file. For the Redux DevTools I do not need to do anything.

To check that everything works, I shared a simple cypress-react-devtools repository. Clone it and follow the instructions to check it the devtools work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Developer Tools
React Developer Tools is a Chrome DevTools extension for the open-source React JavaScript library. It allows you to inspect the React component hierarchies ......
Read more >
React Developer Tools - React Docs
Use React Developer Tools to inspect React components, edit props and state, and identify performance problems. You will learn. How to install React...
Read more >
How To Debug React Components Using React Developer ...
The React Developer Tools browser extension can help you track down these bugs by giving you more insight into the current state for...
Read more >
react-devtools - npm
This package can be used to debug non-browser-based React applications (e.g. React Native, mobile browser or embedded webview, Safari). React ...
Read more >
Top 12 React Developer Tools - Extensions & More DevTools
React Developer Tools (known as Devtools) is a Chrome and Firefox extension that adds a set of React-specific inspection widgets to help you ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found