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>
 
 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

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