SOURCE

console 命令行工具 X clear

                    
>
console
class A extends React.Component{
    constructor (props) {
        super(props)
        this.changeText = this.changeText.bind(this)
    }

    changeText (e) {
        this.props.onTextChange(e.target.value)
    }

    render () {
        let text = this.props.text
        return (
            <div>
                <input value={text} onChange={this.changeText} />
            </div>
        )
    }
}

class B extends React.Component{
    constructor (props) {
        super(props)
        this.state = {
            text: 'A的初始内容'
        }
        this.handleTextChange = this.handleTextChange.bind(this)
    }

    handleTextChange (value) {
        this.setState({
            text: value
        })
    }

    render () {
        let text = this.props.text
        return (
            <div>
                <A text={this.state.text} onTextChange={this.handleTextChange} />
                {this.state.text}
            </div>
        )
    }
}

ReactDOM.render(
    <B/>,
    document.getElementById('root')
)
<div id="root"></div>

本项目引用的自定义外部资源