Created
January 31, 2019 17:56
-
-
Save yuval-a/5f12b454985db7a212a55d12017c3162 to your computer and use it in GitHub Desktop.
React Component class "abstract" prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
export default class ComponentName extends Component { | |
constructor(props) { | |
console.log ("constructor"); | |
super(props); | |
this.state = { | |
}; | |
} | |
componentDidMount() { | |
console.log ("Did mount"); | |
} | |
componentDidUpdate(prevProps, prevState) { | |
console.log ("Did update"); | |
} | |
shouldComponentUpdate(newprops) { | |
console.log ("Should update"); | |
// return false to prevent calling render | |
return true; | |
} | |
componentWillUnmount() { | |
console.log ("Will unmount"); | |
} | |
render() { | |
// return DOM as JSX, or null to render nothing | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment