Created
January 3, 2017 15:16
-
-
Save casprwang/b965ee763591fa425c32b030a17fdfc2 to your computer and use it in GitHub Desktop.
list the items in react
This file contains hidden or 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 from 'react'; | |
// state with render() | |
class Header extends React.Component { | |
name = 'name in the class' | |
render() { | |
// user = { | |
// name: 'Anna', | |
// hobbies: 'Gold' | |
// } | |
let name = 'name in render' | |
let content = | |
<p> | |
content from val | |
</p> | |
if (1) { | |
content = | |
<p> | |
changed content | |
</p> | |
} | |
return ( | |
<h1> | |
{this.props.age}<br/> | |
Hello<br/> | |
{1+1}<br/> | |
{content}<br/> | |
{'hello'}<br/> | |
{ 5===2 ? 'yes': 'no' }<br/> | |
{this.props.user.name}<br/> | |
{this.props.user.hobbies.map((hobby)=> <li>{hobby}</li>)} | |
{[<li>{'hahah'}</li>, | |
<li>{'hohoho'}</li>]} | |
{[<p>{1}</p>, | |
<p>{2}</p>]}<br/> | |
{name}<br/> | |
{this.name}<br/> | |
{this.props.userClass.name} | |
</h1> | |
); | |
} | |
} | |
export default Header |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment