Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deku

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deku

Create view components using a virtual DOM

  • 0.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
538
increased by16.96%
Maintainers
1
Weekly downloads
 
Created
Source

Deku

Sauce Test Status

This project is still a work-in-progress

Create composable, reactive views that use implement a virtual DOM system similar to React. You create components and use lifecycle hooks to change the state of the component.

It has similar capabilities to React:

  • Components return a virtual tree using a render method
  • Lifecycle hooks (beforeMount, afterMount etc.)
  • Optimized tree diffing algorithm
  • Components can be rendered to a string for server-side rendering

But why use Deku instead of React?

  • It's smaller. Roughly 8kb. And built from
  • Readable source
  • No globals or global state
  • Easily testable components without needing Jest
  • It doesn't create virtual events
  • It only supports evergreen browsers
  • Easily add plugins
  • Batched updates using requestAnimationFrame

Install

npm install deku

Example

This example uses ES6 syntax:

var {component, dom} = require('deku');

// Simple button component.
var ButtonComponent = component({
  onClick() {
    this.setState({ clicked: true });
  }
  render(props, state) {
    return dom('button', { onClick: this.onClick }, [props.text]);
  }
});

// Our main app.
var App = component({
  render(props, state) {
    return dom('div', { class: 'App' }, [
      ButtonComponent({ text: props.buttonText })
    ]);
  }
});

// Returns a scene.
var scene = App.mount(document.body, {
  buttonText: 'Click Me!'
});

// We set the props from the top and render the scene top-down
scene.setProps({
  buttonText: 'Do it...'
});

FAQs

Package last updated on 17 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc