J
J
jtag2017-08-20 15:25:12
React
jtag, 2017-08-20 15:25:12

Explain what super(props) and also .bind(this) are for?

class ClickButton extends React.Component {
            constructor(props) {
                super(props);
                this.state = {class: "off", label: "Нажми"};
                this.press = this.press.bind(this);
            }
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
User Unknown, 2017-08-20
@msa6886

  • super(props) - call the constructor of the inherited class, those React.Component
  • .bind(this) - returns a function with hard context binding

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question