arrow function in react js code example
Example 1: defining functions in 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 ;
}
}
Example 2: react arrow funvtion
//declaring arrow function
hello = () => {
return "hello world";
}
Example 3: react native function
class Foo extends Component {
handleClick() {
console.log('Click happened');
}
render() {
return ;
}
}