freeCodeCamp.org React: Use the Lifecycle Method componentWillMount 32/47

Objective:

React components have several special methods that provide opportunities to perform actions at specific points in the lifecycle of a component. These are called lifecycle methods, or lifecycle hooks, and allow you to catch components at certain points in time. This can be before they are rendered, before they update, before they receive props, before they unmount, and so on. Here is a list of some of the main lifecycle methods: componentWillMount() componentDidMount() shouldComponentUpdate() componentDidUpdate() componentWillUnmount() The next several lessons will cover some of the basic use cases for these lifecycle methods.
Note: The componentWillMount Lifecycle method will be deprecated in a future version of 16.X and removed in version 17. (Source)

The componentWillMount() method is called before the render() method when a component is being mounted to the DOM. Log something to the console within componentWillMount() – you may want to have your browser console open to see the output.

Solution:

This one is really simple! It is basic console.log ("Hello World! ") task:

console.log ("Hello World!");

If you didn’t know it, it’s just your brain has been twisted by overthinking. Very good task!

By swiatartura

Aspiring Webdeveloper, practising LifeHacker, bicycle and qigong enthusiast, father, member of 40 years old society.

Leave a comment