deku

Render interfaces using pure functions and virtual DOM

  • 所有者: anthonyshort/deku
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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 5 modules packaged together for convenience:

  • element: Create virtual elements.
  • diff: Compute the difference between two virtual elements. You can use this if you're creating a custom renderer.
  • dom: Create DOM elements from virtual elements and update them using the result of a diff. You'll only use this directly if you're building your own app creator.
  • string: Render a HTML string from virtual elements.
  • createApp: Kickstart an app for the browser.

Installation

npm install --save deku

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

Sauce Test Status

Example

/** @jsx element */
import {element, createApp} from 'deku'
import {createStore} from 'redux'
import reducer from './reducer'

// 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 an app that can turn vnodes into real DOM elements
let render = createApp(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

概覽

名稱與所有者anthonyshort/deku
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證
發布數93
最新版本名稱v2.0.0-rc16 (發布於 2016-01-25 21:43:53)
第一版名稱0.0.1 (發布於 2014-10-24 21:58:57)
創建於2014-08-08 04:32:23
推送於2018-07-10 06:28:41
最后一次提交2016-09-10 17:13:54
星數3.4k
關注者數89
派生數131
提交數1.1k
已啟用問題?
問題數235
打開的問題數28
拉請求數145
打開的拉請求數7
關閉的拉請求數46
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部