react lifecycle example
class Test extends React.Component {
constructor() {
console.log('Constructor')
super();
this.state = {
count: 0
};
}
componentDidMount() {
console.log("component did mount");
}
componentDidUpdate() {
console.log("component did update");
}
onClick = () => {
this.setState({ count: this.state.count + 1 });
};
render() {
console.log("render");
return (
<div>
Hello Test
<button onClick={this.onClick}>
{this.state.count}
</button>
</div>
);
}
}
//--for first time
//Constructor
//render
//component did mount
//--for any update
//render
//component did updateconstructor(props) {
super(props);
// Don't call this.setState() here!
this.state = { counter: 0 };
this.handleClick = this.handleClick.bind(this);
}
Also in JavaScript:
- jquery cancel ajax request on click
- javascript email validation
- angular new service
- check if js is enabled
- ansi encoding "vscode"
- navigation in react native
- object destructuring into this
- javascript iterate through object
- jquery datepicker
- jquery set select value
- convert image url to base64 javascript
- 00:00:00 / 00:00:00 js
- reverse a string program in javascript
- change elements class javascript
- javascript cast bool to int
- multiplication of complex numbers javascript
- firstElementChild jquery equivalent
- filter out arrays js
- how to sort array least to greatest javascript stACK
- checking if var is not defined js
- build a trivia and answer javascript
- .change() in pure js
- javascript array syntax
- how to add alternate image in img tag in react