An open API service indexing awesome lists of open source software.

https://github.com/dawee/react-dispersive

React binding for Dispersive
https://github.com/dawee/react-dispersive

Last synced: 3 months ago
JSON representation

React binding for Dispersive

Awesome Lists containing this project

README

          

# react-dispersive

Binding of [dispersive](http://github.com/dawee/dispersive) for [react](http://github.com/facebook/react) components.

## Install

This package has 2 peer dependencies : [dispersive](http://github.com/dawee/dispersive) and [react](http://github.com/facebook/react).

```sh
npm install dispersive react react-dispersive
```

## Usage

```jsx
import React, {Component} from 'react';
import classNames from 'classnames';
import {createModel} from 'dispersive/model';
import {withField} from 'dispersive/field';
import {createAction} from 'dispersive/action';
import {Watcher} from 'dispersive-react';

const Todo = createModel([
withField('text'),
withField('checked'),
]);

const toggleTodo = createAction(todo => todo.update({checked: !todo.checked}));
const addTodo = createAction(text => Todo.objects.create({text}));

const TodoItem = ({todo}) => {
const className = classNames('todo', todo.checked ? 'checked' : null);

return (

  • toggleTodo(todo)}>
    {todo.text}

  • );
    };

    const TodoList = () => (


      {Todo.objects.map(todo => )}

    );

    class TodoForm extends Component {

    submit = (event) => {
    event.preventDefault();
    addTodo({text: this.input.value});
    }

    render() {
    return (

    this.input = input} />

    );
    }
    }

    class App = () => (






    );

    export default App;
    ```