| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: Render State in the User Interface Another Way | 
					
						
							|  |  |  | --- | 
					
						
							| 
									
										
										
										
											2019-07-24 00:59:27 -07:00
										 |  |  | # Render State in the User Interface Another Way
 | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-24 00:59:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | ## Hints
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Hint 1
 | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | ```JSX | 
					
						
							|  |  |  | class MyComponent extends React.Component { | 
					
						
							|  |  |  |   constructor(props) { | 
					
						
							|  |  |  |     super(props); | 
					
						
							|  |  |  |     this.state = { | 
					
						
							|  |  |  |       name: 'freeCodeCamp' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   render() { | 
					
						
							|  |  |  |     // change code below this line | 
					
						
							|  |  |  |             // Remember that how you can access the property of a state. | 
					
						
							|  |  |  |     // change code above this line | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <div> | 
					
						
							|  |  |  |         { /* change code below this line */ } | 
					
						
							|  |  |  |             // Just use the const "name" inside the h1 tag. | 
					
						
							|  |  |  |             // Dont forget to use JSX syntax "{ curly braces for JavaScript }". | 
					
						
							|  |  |  |         { /* change code above this line */ } | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-24 00:59:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | ## Solutions
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <details><summary>Solution 1 (Click to Show/Hide)</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | ```JSX | 
					
						
							|  |  |  | class MyComponent extends React.Component { | 
					
						
							|  |  |  |   constructor(props) { | 
					
						
							|  |  |  |     super(props); | 
					
						
							|  |  |  |     this.state = { | 
					
						
							|  |  |  |       name: 'freeCodeCamp' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   render() { | 
					
						
							|  |  |  |     // change code below this line | 
					
						
							|  |  |  |     const name = this.state.name; | 
					
						
							|  |  |  |     // change code above this line | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <div> | 
					
						
							|  |  |  |         { /* change code below this line */ } | 
					
						
							|  |  |  |           <h1>{name}</h1> | 
					
						
							|  |  |  |         { /* change code above this line */ } | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2019-07-24 00:59:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | </details> |