@react-rangers/stateful

1.1.1 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i @react-rangers/stateful

Weekly Downloads

3

Version

1.1.1

License

MIT

Unpacked Size

6.31 kB

Total Files

9

Last publish

Collaborators

  • mhagmajer