devdropper87 devdropper87 - 5 months ago 21
AngularJS Question

debugging with pre tags - angularjs/reactjs

I use pre tags extensively to debug my code in angular js, like so:

<pre>{{vm.names | json}}</pre>


Two questions:


  1. how does this work under the hood?

  2. is there an equivalent tool
    with reactjs that lets you see variables' values in the view, instead
    of the more common console.logs/debuggers?


Answer

You can add <pre>{JSON.stringify(this.state.data, null, 4)}</pre> to the Component holding state to "visualize" the data in your view.