Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-0.14.7.min.js"></script>
<script src="https://fb.me/react-dom-0.14.7.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
    <script src="https://rawgit.com/baconjs/bacon.js/master/dist/Bacon.js"></script>
</head>
<body>
</body>
</html>
 
// BaconJS (store)
const nameBus = new Bacon.Bus()
const fullData = Bacon.combineTemplate({
  name: nameBus.toProperty("")
})
// Event handlers (actions)
// this listener function is used below in the HelloWorld component whenever the text box changes
const buttonChange = (e) => {
  nameBus.push(e.target.value)
}
// Function component (view)
// (react component)
const HelloWorld = (props) => 
  (<div>
    <h1>Hello {props.name}</h1>
    <input type="text" onChange={buttonChange} />
  </div>);
  
// Tie everything in a bow
// (arg) => {} is ES6 shorthand of a function
// the ... (spread) operator in ES6 passes all of the properties of the object to the react component
fullData.onValue((data) => {
  ReactDOM.render(<HelloWorld {...data} />, document.body);
})
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers