Last active
July 18, 2019 17:54
-
-
Save RyanAtViceSoftware/27ec782a76990860929b to your computer and use it in GitHub Desktop.
Hello React - composite components - how to componse simple components. JsFiddle: http://jsfiddle.net/gh/gist/library/pure/27ec782a76990860929b/
This file contains 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
<script src="https://fb.me/react-with-addons-0.14.0.js"></script> | |
<script src="https://fb.me/react-dom-0.14.0.js"></script> | |
<div id="view"/> |
This file contains 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
var HelloMessage = React.createClass({ | |
render: function() { | |
return <div>{this.props.message}</div>; | |
} | |
}); | |
var HelloReact = React.createClass({ | |
getInitialState: function() { | |
return { message: 'default'} | |
}, | |
updateMessage: function () { | |
console.info('updateMessage'); | |
this.setState({ | |
message: this.refs.messageTextBox.value | |
}); | |
}, | |
render: function() { | |
return ( | |
<div> | |
<HelloMessage message='Hello React'></HelloMessage> | |
<input type='text' ref='messageTextBox' /> | |
<button onClick={this.updateMessage}>Update</button> | |
<div>{this.state.message}</div> | |
</div> | |
); | |
} | |
}); | |
ReactDOM.render( | |
<HelloReact/>, | |
document.getElementById('view')); |
This file contains 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
name: ReactJs example by Ryan Vice - www.ViceSoftware.com | |
description: Hello React - composite components - how to componse simple components. | |
authors: | |
- Ryan Vice | |
resources: | |
normalize_css: no | |
wrap: h | |
panel_js: 3 | |
panel_css: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment