2018-10-04 14:47:55 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Use the Lifecycle Method componentWillMount
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Use the Lifecycle Method componentWillMount
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The challenge is a basic introduction to React's LifeCycle components.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These methods are also called Lifecycle Hooks.
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:47:55 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Hint 1
  
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:47:55 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Log something to the console in the ```react componentWillMount ` `` method.
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 01:24:55 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Hint 2
  
						 
					
						
							
								
									
										
										
										
											2018-10-16 01:24:55 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The `` console.log(); ` ` statement is used to log to the browser console.
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 01:24:55 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Solution
  
						 
					
						
							
								
									
										
										
										
											2018-10-16 01:24:55 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Since you can log anything, use the ``` console.log(); ` `` and pass in a string. The ` `` componentWillMount ` `` method should look like:
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 01:24:55 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 14:14:34 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								componentWillMount() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  console.log('Component being mounted');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 01:24:55 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 15:48:05 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								##### Note: The ``` componentWillMount ``` Lifecycle method has been deprecated as of version 17, and does not work on later versions. [(Source)](https://reactjs.org/docs/react-component.html)