Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 809 Bytes

README.md

File metadata and controls

35 lines (29 loc) · 809 Bytes

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={({ count }) => this.setState({ count: count + 1})}>
      {state.count}
    </button>    
  }
}

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