Skip to content

gwing33/react-plunge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Plunge

NOT IMPLIMENTED YET: See Plunge for more info on that.

React Plunge is a High Order Function that binds store like data to a component as props. State is preserved within the React Plunge Component

TODO

  • Get the proof of concept working.
  • Write tests around the component.
  • Get an example up and running.

Install

npm install react-plunge

Usage

'use strict';
import React from 'react';
import plunge from 'react-plunge';

class Index extends React.Component {
  _onClick() {
    this.props.ApiData.store.add({
      clicks: this.props.ApiData.data.clicks + 1
    });
  }

  render() {
    let clicks = this.props.ApiData.data.clicks;
    let text = clicks == 1 ? 'Beer' : 'Beers';

    return (
      <div styles={[ LayoutStyle.center, LayoutStyle.half, styles.container ]}>
        <div styles={styles.number}>
          {clicks} {text} Donated
        </div>
        <button type='text' onClick={this._onClick.bind(this)} value='Donate a beer'/>
      </div>
    );
  }
}

let ApiData = {
  name: 'ApiData',
  uri: '/api/data',
  data: {
    clicks: 0
  }
};

export default plunge(Index, [ApiData]);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published