1.1.1 • Published 6 years ago

@react-rangers/stateful v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Stateful

An easy way to write stateful React components

import Stateful from '@react-rangers/stateful';

const App = () => (
  <Stateful initialState={{ count: 0 }}>
    {state => (
      <button onClick={() => { state.count += 1; }}>
        {state.count}
      </button>
    )}
  </Stateful>  
)

Here's the same app written in standard way as of React 16

class App extends React.Component {
  state = {
    count: 0,
  };

  render() {
    <button onClick={() => this.setState({ count: state.count + 1})}>
      {state.count}
    </button>    
  }
}

Please check out the introductory blog post for more documentation and usage examples.