只是稍微扩展一下 WiredPrairie 的答案,一个可以打开和关闭的迷你组件。
可以像这样使用:
<Pretty data={this.state.data}/>

export default React.createClass({
    style: {
        backgroundColor: '#1f4662',
        color: '#fff',
        fontSize: '12px',
    },
    headerStyle: {
        backgroundColor: '#193549',
        padding: '5px 10px',
        fontFamily: 'monospace',
        color: '#ffc600',
    },
    preStyle: {
        display: 'block',
        padding: '10px 30px',
        margin: '0',
        overflow: 'scroll',
    },
    getInitialState() {
        return {
            show: true,
        };
    },
    toggle() {
        this.setState({
            show: !this.state.show,
        });
    },
    render() {
        return (
            <div style={this.style}>
                <div style={this.headerStyle} onClick={ this.toggle }>
                    <strong>Pretty Debug</strong>
                </div>
                {( this.state.show ?
                    <pre style={this.preStyle}>
                        {JSON.stringify(this.props.data, null, 2) }
                    </pre> : false )}
            </div>
        );
    }
});
更新
一种更现代的方法(现在 createClass 即将淘汰)
import styles from './DebugPrint.css'
import autoBind from 'react-autobind'
import classNames from 'classnames'
import React from 'react'
export default class DebugPrint extends React.PureComponent {
  constructor(props) {
    super(props)
    autoBind(this)
    this.state = {
      show: false,
    }
  }    
  toggle() {
    this.setState({
      show: !this.state.show,
    });
  }
  render() {
    return (
      <div style={styles.root}>
        <div style={styles.header} onClick={this.toggle}>
          <strong>Debug</strong>
        </div>
        {this.state.show 
          ? (
            <pre style={styles.pre}>
              {JSON.stringify(this.props.data, null, 2) }
            </pre>
          )
          : null
        }
      </div>
    )
  }
}
还有你的样式文件
.root { backgroundColor: '#1f4662'; 颜色:'#fff'; 字体大小:'12px'; }
.header { backgroundColor: '#193549'; 填充:'5px 10px'; fontFamily: '等宽'; 颜色:'#ffc600';}
.pre { 显示:'块'; 填充:'10px 30px'; 边距:'0'; 溢出:'滚动';}