Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE HTML>
<body>
<script src="https://fb.me/react-with-addons-0.14.7.min.js"></script>
<script src="https://fb.me/react-dom-0.14.7.min.js"></script>
<script src="https://npmcdn.com/mobx@2.4.2/lib/mobx.umd.js"></script>
<script src="https://npmcdn.com/mobx-react@3.0.0/index.js"></script>
  <div id="app" />
</body>
 
button, li { cursor: pointer }
.selected {
  color: red;
}
 
const {observable, autorun, transaction} = mobx;
const {observer} = mobxReact;
class AppState {
  @observable myValue = '';
}
const state = new AppState();
@observer
class App extends React.Component {
  handleChange = (e) => {
    this.props.appState.myValue = e.target.value; 
  };
  render() {
    const { appState } = this.props;
    return (
      <div>
        <input value={appState.myValue} onChange={this.handleChange} />
        value: {appState.myValue}
      </div>
    );
  }
}
ReactDOM.render(
  <App appState={state} />,
  document.getElementById('app')
);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers