Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<script src="//fb.me/react-with-addons-0.12.0.js"></script>
<div id="greeting"></div>
 
body {
  background: #fff;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;;
  font-size: 20px;
  line-height: 1.7;
  margin: 0;
  padding: 30px;
}
h1 {
  border-bottom: 1px solid #ddd;
  font-size: 1.5em;
  font-weight: bold;
  margin: 0 0 15px;
  padding: 0;
}
p, ul {
  margin: 22px 0;
}
 
 var Greeter = React.createClass({
        getInitialState : function() {
          return {
            name : "Welt"
          };
        },
        handleClick : function() {
          if(this.state.name=="Welt"){
            this.replaceState({
              name : "Webkrauts"
            });
          }else{
            this.replaceState({
              name : "Welt"
            });
          }
        },
        render: function() {
          var greeterCSS = {
            backgroundColor: '#CACACA',
            color: '#FFFFFF',
            fontSize: '2em',
            textAlign: 'center',
            width: 400,
            cursor: 'pointer'
          };
          return (
            <p style={greeterCSS} onClick={this.handleClick}>Hallo {this.state.name}!</p>
          )
        }
      });
      React.render(
        <Greeter />,
        document.getElementById('greeting')
      );
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers