SHARE
TWEET

Untitled

a guest Jul 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* React components have several special methods that provide opportunities to perform actions at specific points in the
  2. lifecycle of a component. These are called lifecycle methods, or lifecycle hooks, and allow you to catch components at
  3. certain points in time. This can be before they are rendered, before they update, before they receive props, before they
  4. unmount, and so on. Here is a list of some of the main lifecycle methods:
  5.  
  6. componentWillMount()
  7.  
  8. componentDidMount()
  9.  
  10. componentWillReceiveProps()
  11.  
  12. shouldComponentUpdate()
  13.  
  14. componentWillUpdate()
  15.  
  16. componentDidUpdate()
  17.  
  18. componentWillUnmount()
  19.  
  20. The next several lessons will cover some of the basic use cases for these lifecycle methods.
  21. The componentWillMount() method is called before the render() method when a component is being mounted to the DOM.
  22. Log something to the console within componentWillMount() - you may want to have your browser console open to see the output.
  23.  
  24. */
  25.  
  26. class MyComponent extends React.Component {
  27.   constructor(props) {
  28.     super(props);
  29.   }
  30.   componentWillMount() {
  31.     // change code below this line
  32.     console.log(" The componentWillMount() method is called before the render() method when a component is being mounted to the DOM")
  33.     // change code above this line
  34.   }
  35.   render() {
  36.     return <div />
  37.   }
  38. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top