Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Service Chooser
'app/js/jsx/reactComponents/Service' // this 'child view' needs to be loaded before calling render on ServiceChooser, so that we can require it synchronously in the render function
function (React, Service, require) {
var ServiceChooser = React.createClass({
getInitialState: function () {
return {total: 0};
addTotal: function (price) {
this.setState({total: + price});
render: function () {
var self = this;
Service = require('app/js/jsx/reactComponents/Service'); //here we re-evaluate the reference so that it stays up to date as we hot-reload repeatedly
var services = (s) {
return <Service name={} price={s.price} active={} addTotal={self.addTotal}/>;
return (<div>
<h1>Our services</h1>
<div id="services">
<p id="total">Total <b>${}</b></p>
return ServiceChooser;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.