Answers for "function inside a class component react"

0

function inside a class component react

export default class Archive extends React.Component { 

    saySomething(something) {
        console.log(something);
    }

    handleClick(e) {
        this.saySomething("element clicked");
    }

    componentDidMount() {
        this.saySomething("component did mount");
    }

    render() {
        return <button onClick={this.handleClick.bind(this)} value="Click me" />;
    }
}
Posted by: Guest on April-26-2020

Code answers related to "function inside a class component react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language