-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Anmol Singh edited this page Nov 21, 2019
·
6 revisions
LC 1.
shouldComponentUpdate = (nextProps, nextState) => {
console.log("nextProps===>>>", nextProps)
console.log("nextState===>>>", nextState)
return true
}
componentWillUpdate = (nextProps, nextState) => {
console.log("nextProps===>>>", nextProps)
if(this.state === nextState) {
this.setState({
})
}
}LC 2.
shouldComponentUpdate = (nextProps, nextState) => {
console.log("nextProps===>>>", nextProps)
console.log("nextState===>>>", nextState)
return true
}
getSnapshotBeforeUpdate = () => {
console.log("Test")
// return null
// return {message: "SanapShot!"}
}
componentDidUpdate = (prevProps, prevState, snapshot) => {
console.log("Test")
console.log("snapshot===>>", snapshot)
}componentWillUnmount() {
console.log("unmount===>>")
}Note:- Run right before the component is removed (cleanUp Work).
useEffect(() => {
console.log("useEffect===>>")
setTimeout(() => {
alert("saved data to cloud")
}, 1000)
}, [])Note:- [ ] point all the variable or data.
we can write [ ] as requirement else not
we can write multiple useEffect