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://cdnjs.cloudflare.com/ajax/libs/mobx/3.2.2/mobx.umd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mobx-react/4.2.2/index.js"></script>
  <div id="app" />
</body>
 
button, li { cursor: pointer }
.selected {
  color: red;
}
 
const { observable } = mobx;
const { observer } = mobxReact;
const { Component } = React;
@observer 
class App extends Component {
  @observable value = ''
  
  componentDidMount() {
    setTimeout(() => this.value = 'focus', 1000);
  }
  
  componentDidUpdate() {
    this.ref.focus();
  }
  
  render() {
    return (
      <input
        ref={ref => this.ref = ref}
        value={this.value}
        onChange={e => this.value = e.target.value}
      />
    );
  }
};
ReactDOM.render(
  <App />,
  document.getElementById('app')
);
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