0.2.0 • Published 5 years ago

dio-react v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

dio-react

NPM

Install

yarn add @bearmoth/dio-react

Usage

import React, { Component } from 'react'
import DIO from 'dio-react'

const input = () => ({ onChange, className }) => <input onChange={onChange} className={className} />;

const output = ({ results, className }) => results === undefined ?
  <div className={className}>Preview component goes here</div> :
  <div className={className}>Results component goes here</div>;

const DIOComponent = DIO(InputComponent, OutputComponent);

class Example extends Component {
  constructor(props) {
    super(props);
    this.state = { 
      results: undefined
     };
    this.onChange = this.onChange.bind(this);
  }

  onChange(event) {
    // handle change event and update state
  }

  render () {
    const { results } = this.state;
    const onChange = this.onChange;
    return (
      <DIOComponent results={results} onChange={onChange} />
    )
  }
}

License

MIT © bearmoth