@rstacruz/deku
Render interfaces using pure functions and virtual DOM
Last updated 5 years ago by rstacruz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @rstacruz/deku 
SYNC missed versions from official npm registry.

Deku

version version js-standard-style npm downloads discord

Deku is a library for rendering interfaces using pure functions and virtual DOM.

Instead of using classes and local state, Deku just uses functions and pushes the responsibility of all state management and side-effects onto tools like Redux. It also aims to support only modern browsers to keep things simple.

It can be used in place of libraries like React and works well with Redux and other libraries in the React ecosystem.

Deku consists of 4 modules packaged together for convenience:

  • element: Creating virtual elements
  • diff: Computing the difference between two virtual elements
  • dom: DOM renderer
  • string: HTML string renderer

Installation

npm install --save deku

We support the latest two versions of each browser. This means we only support IE10+.

Sauce Test Status

Example

import {dom, element} from 'deku'
import {createStore} from 'redux'
import reducer from './reducer'
let {createRenderer} = dom

// Dispatch an action when the button is clicked
let log = dispatch => event => {
  dispatch({
    type: 'CLICKED'
  })
}

// Define a state-less component
let MyButton = {
  render: ({ props, children, dispatch }) => {
    return <button onClick={log(dispatch)}>{children}</button>
  }
}

// Create a Redux store to handle all UI actions and side-effects
let store = createStore(reducer)

// Create a renderer that can turn vnodes into real DOM elements
let render = createRenderer(document.body, store.dispatch)

// Update the page and add redux state to the context
render(
  <MyButton>Hello World!</MyButton>,
  store.getState()
)

Documentation

You can read the documentation online.

License

The MIT License (MIT) Copyright (c) 2015 Anthony Short

Current Tags

  • 2.0.0-rc6-13-g5adfbd4                                ...           latest (5 years ago)

2 Versions

  • 2.0.0-rc6-13-g5adfbd4                                ...           5 years ago
  • 2.0.0-rc6-4-g6c4b3a1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (18)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |