How do you inspect a react element's props & state in the console?

前端 未结 5 2048
暗喜
暗喜 2021-01-30 12:24

React Developer Tools give a lot of power to inspect the React component tree, and look at props, event handlers, etc. However, what I\'d really like to do is to be able to insp

5条回答
  •  难免孤独
    2021-01-30 13:03

    Assign the state or prop object to the window object:

    window.title = this.state.title
    

    And then from the dev tools console you can try different methods on the exposed object such as:

    window.title.length
    

    8

提交回复
热议问题