GithubHelp home page GithubHelp logo

xiaoqqchen / deku Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anthonyshort/deku

0.0 2.0 0.0 2.51 MB

Render interfaces using pure functions and virtual DOM

Home Page: https://github.com/anthonyshort/deku/tree/master/docs

JavaScript 100.00%

deku's Introduction

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

deku's People

Contributors

aeosynth avatar alepop avatar anthonyshort avatar archywillhe avatar bcinman avatar boopathi avatar call-a3 avatar chrisbuttery avatar dominicbarnes avatar dylanpiercey avatar gillstrom avatar gitter-badger avatar greenkeeperio-bot avatar joedski avatar josepedrodiassky avatar kesla avatar kohei-takata avatar kvnneff avatar lancejpollard avatar olivierlacan avatar rivergrimm avatar rstacruz avatar seanstrom avatar stevenhauser avatar svnm avatar tejasmanohar avatar tel avatar voronianski avatar xdissent avatar yomguithereal avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.