onClick doesn't render new react component.

前端 未结 4 1361
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 17:37

I\'m new to react world and I have line like this:


and on cli

4条回答
  •  粉色の甜心
    2020-11-27 18:20

    Here's a CodePen to show it in action.

    HTML

    loading...

    JSX

    class NewComponent extends React.Component {
      render() {
        return (
          
    new component
    ); } } class Button extends React.Component { render() { return ( ); } } class App extends React.Component { constructor() { super(); this.state = { clicked: false }; this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState({ clicked: true }); } render() { return (
    ); } }; React.render( , document.getElementById("root") );

提交回复
热议问题