Skip to content

ReactRangers/stateful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

An easy way to write stateful React components

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published