cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              body {
  max-width: 1024px;
  padding: 20px;
  margin: 50px auto;
}
            
          
!
            
              // step 1
const User = props => {
  return <div>HELLO WIDGET</div>;
}

// step 2
const User2 = props => {
  return React.createElement('div', {...props}, 'THIS IS THE WIDGET 2');
}

const Admin = props => <li>Admin {props.label}</li>;
const Guest = props => <li>Guest {props.label} - <button>ban</button></li>;

// step 3
const User3 = props => {
  return React.createElement(props.type, {...props}, null);
}

// step 4
const User4 = props => {
  let component;
  switch(props.type) {
    case 'admin':
      component = Admin;
      break;

    default:
    case 'guest':
      component = Guest;
      break;
  }
  return React.createElement(component, {...props}, 'ciao');
}

// Step 5
const List = props => {
  return <ul>{props.users.map(t => <User4 {...t}></User4>)}</ul>;
}


class App extends React.Component {
  render() {
    return (
      <div>
        <User />
        <User2 />
        <hr />
        <User3 type={Admin} label="Pippo" />
        <User3 type={Guest} label="Pluto" />
        <hr />
        <User4 type="admin" label="Paperino" />
        <User4 type="guest" label="Topolino" />
        <hr />
        <List users={this.props.users}/>
      </div>
    );
  }
}

const users = [
  { label: 'Mario Biondi', type: 'admin' },
  { label: 'Lorenzo Verdi', type: 'guest' },
  { label: 'Silvia Bianchi', type: 'guest' },
  { label: 'Lisa Arancio', type: 'guest' }
];

ReactDOM.render(
   <App users={users} />, 
  document.getElementById('content')
);

            
          
!
999px
Loading ..................

Console