Coder Social home page Coder Social logo

Comments (9)

yonatanmn avatar yonatanmn commented on May 5, 2024 7

@Zinggi I had the same problem. following @jaredly 's solution, I've added script tag to index.html
<script> __REACT_DEVTOOLS_GLOBAL_HOOK__ = parent.__REACT_DEVTOOLS_GLOBAL_HOOK__ </script>
now it is working! (thanks @jaredly !!!)

from react-devtools.

jaredly avatar jaredly commented on May 5, 2024 3

I have a small working example in this gist.

from react-devtools.

Zinggi avatar Zinggi commented on May 5, 2024 2

@jaredly, @yonatanmn:
It works! Thanks a lot!

I tried following the gist before, but I tried putting __REACT_DEVTOOLS_GLOBAL_HOOK__ = parent.__REACT_DEVTOOLS_GLOBAL_HOOK__ in my script file, before require("react"), but that didn't work.

So yes, the suggested solution works, this does the trick:
in index.html:

  <script> __REACT_DEVTOOLS_GLOBAL_HOOK__ = parent.__REACT_DEVTOOLS_GLOBAL_HOOK__ </script>
  <script type="text/javascript" src="main.js"></script>

from react-devtools.

jaredly avatar jaredly commented on May 5, 2024

They changed the way that react exposes itself to the devtools. What you need to do is, before react is loaded in the child iframe, do window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__.

That ought to work.

from react-devtools.

Zinggi avatar Zinggi commented on May 5, 2024

That still doesn't work for me, window.__REACT_DEVTOOLS_GLOBAL_HOOK__ is defined, but it's not helping. window.React is also defined.

The React tab just doesn't want to show up.

I'm also using react-router, maybe this causes some problems in this constellation?

from react-devtools.

Zinggi avatar Zinggi commented on May 5, 2024

I still can't get it to work.

These are all the relevant versions:

react 0.12.1
react-router 0.11.4
react-hot-loader 0.5.0
webpack 1.4.13
webpack-dev-server 1.6.6

The devtools work perfectly if I build my project, but not with the hot loader setup.
The devtools also work nice on other sites made with React.

With my setup that doesn't work, __REACT_DEVTOOLS_GLOBAL_HOOK__ is correctly exposed, but it's no use. (Using window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__ or not makes no difference)
If I print it in the console, I get this:

> __REACT_DEVTOOLS_GLOBAL_HOOK__
< Object {inject: function, getSelectedInstance: null, Overlay: null}

Is there maybe a way to manually inject the devtools?
Or how exactly does this inject process work?

from react-devtools.

yonida avatar yonida commented on May 5, 2024

how can you do this when the iframe has a different origin?
I'm getting the following error: Uncaught SecurityError: Blocked a frame...

from react-devtools.

ibash avatar ibash commented on May 5, 2024

For @yonida you can disable security in chrome to get it to work.
But realize, you are literally disabling security, so you don't want to use this for normal browsing, use a dedicated chrome instance for this.

TLDR: Add this alias command to your .bash_profile and use it to startup an insecure instance of chrome (from which you can get the trick above to work):

alias insecure="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security --user-data-dir=/Users/$USER/Library/Application\\ Support/Google/ChromeInsecure > /dev/null 2>&1 &"

ref: http://stackoverflow.com/a/6083677/418739

from react-devtools.

yonida avatar yonida commented on May 5, 2024

Thanks @ibash

from react-devtools.

Related Issues (20)

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.