Skip to content

Instantly share code, notes, and snippets.

@caub caub/Sux.js
Last active Jun 28, 2019

What would you like to do?
simple react state management
import React from 'react';
const SuxContext = React.createContext();
export class SuxProvider extends React.Component {
state = {};
render() {
return (
<SuxContext.Provider value={{...this.state, dispatch: data => this.setState(data)}}>
// usage <Sux>{({foo}) => <div>{foo}</div>}</Sux>
export default SuxContext.Consumer;
export const withSux = Component => props => (
{data => <Component {...props} {} />}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.