Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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.

+ add another resource

Behavior

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              
            
          
!

CSS

            
              
            
          
!

JS

            
              OverReact = (function() {
  let context = {};
  let callId = -1;
  function render (Component) {
    context.Component = Component;
    const instance = Component();
    instance.render();
    // reset the callId after every render
    callId = -1;
    // ensuring that instance.render is not available out OverReact.render
    delete instance.render;
    context.instance = instance;
    return context;
  }
  function useState(initialState) {
    if (!context) {
      throw new Error('hooks can not be called with out a rendering context');    
    }
    if (!context.hooks) {
      context.hooks = [];
    }
    
    callId = callId + 1;
    
    const hooks = context.hooks;
    const currentState = hooks[callId] ? hooks[callId] : initialState;
    hooks[callId] = currentState;
    const setState = function () {
      const currentCallId = callId;
      return function (newState) {
        hooks[currentCallId] = newState;
        render(context.Component);  
      }
    }();  
  
    return [currentState, setState];
  }
  return {
    render,
    useState
  }
}());
const { render, useState } = OverReact;
function Component() {
  const [counter, setCounter] = useState(0);
  const [name, setName] = useState('foo');
  
  function plusOne() {
    setCounter(counter + 1);
  }
  
  function updateName(name) {
    setName(name);
  }
function render() {
    console.log(`rendered, counter: ${counter}, name: ${name}`);   
  }
  
  return {
    render,
    plusOne,
    updateName
  }
}
// initial render
// context is returned by the OverReact.render method
const context = render(Component);
// rendered, counter: 0, name: foo
context.instance.plusOne();
// rendered, counter: 1, name: foo
context.instance.updateName('bar');
// rendered, counter: 1, name: bar
context.instance.plusOne();
// rendered, counter: 2, name: bar
context.instance.updateName('baz');
// rendered, counter: 2, name: baz
context.instance.plusOne();
// rendered, counter: 3, name: baz
            
          
!
999px

Console