Last active
March 3, 2018 03:34
-
-
Save bignimbus/9e20697fdb2f3ab4c55703e67a7bf63d to your computer and use it in GitHub Desktop.
React presentation source code examples
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
// From reactjs.org tutorial | |
class Square extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { value: null }; | |
} | |
render() { | |
return ( | |
<button className="square" onClick={() => alert('click')}> | |
<span style={{ color: 'red' }}>{this.props.value}</span> | |
</button> | |
); | |
} | |
} |
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
<Menu | |
onClick={() => { | |
this.setState({ hide: !this.state.hide }) | |
} | |
> | |
<nav id='global-nav'> | |
<ul> | |
<li><a href='/foo'>Foo</a></li> | |
<li><a href='/bar'>Bar</a></li> | |
<li><a href='/baz'>Baz</a></li> | |
</ul> | |
</nav> | |
</Menu> |
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
class Square extends React.Component { | |
render() { | |
return ( | |
<button className="square"> | |
{this.props.value} | |
</button> | |
); | |
} | |
} |
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
<div> | |
<ul> | |
<li> | |
<Square /> | |
</li> | |
<li> | |
<Square /> | |
</li> | |
</ul> | |
<p> | |
Lorem ipsum | |
</p> | |
</div> |
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
<ol> | |
<% %w(One Two).each do |n| %> | |
<li><%= n %></li> | |
<% end %> | |
</ol> |
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
<ol> | |
<li>One</li> | |
<li>Two</li> | |
</ol> |
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
<ol> | |
{ | |
['One', 'Two'] | |
.map((str, i) => <li key={i}>{ str }</li>) | |
} | |
</ol> |
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
React.createElement( | |
'ol', | |
null, | |
['One', 'Two'].map((str, i) => React.createElement( | |
'li', | |
{ key: i }, | |
str | |
)) | |
); |
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
class Square extends React.Component { | |
render() { | |
return React.createElement( | |
"button", | |
{ className: "square" }, | |
this.props.value | |
); | |
} | |
} |
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
document.createElement('button'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment