React doc and method [SOLVED]

React doc and method [SOLVED]
0

#1

Hi,
I’m using a method: getInitialState()
But I don’t find the definition in the doc?
Same for onChange and defaultCheck

    <script type="text/babel">
      let Checkbox = React.createClass({
        getInitialState(){
          return { 
            checked : false 
          }
        },
        handleCheck() {
          this.setState( { checked : !this.state.checked } )
        },
        render() {
          let msg
          if (this.state.checked) {
            msg='checked'
          } else{
            msg='unchecked'
          } 
          
          return (
            <div>
              <input type='checkbox' onChange={this.handleCheck} defaultChecked={this.state.checked} />
              <p>This box is {msg}</p>
            </div>
          );
        }
      });

      ReactDOM.render(
        <Checkbox/>,
        document.querySelector('.react-container')
      )
    </script>

#2

I found it:


#3

You’re better with using ES6 as most of the examples and resources are written in ES6
.


#4

Thanks for this information, I follow a tuto, and they’re using this syntaxe


#5

Differences are not that many but still, you’ll find ES6 super useful, specially the arrow function so you don’t have to bind everything.


#6

I just started React 2 days ago, I have no idea, but the POO syntaxe why not, for me is fine.