g-easy is a simple global state manager

To Install

npm i --save g-easy

At your top level, set up a provider to access your state anywhere in the tree



import { Provider } from 'g-easy'

import React, { Component } from 'react'; import { Provider } from 'g-easy'; class App extends Component { const initialState = {}; render() { return ( <Provider initialState={initialState}> <MyApp /> </Provider> ); } } export default App;

Use connect to connect your component and access your state anywhere in the tree..

import { connect } from 'g-easy'

export default connect(MyApp);



It will be accessibly as:

this.props.state



import React, { Component } from 'react'; import { connect } from 'g-easy'; class MyApp extends Component { render() { return <>{JSON.stringify(this.props.state)}</>; } } export default connect(MyApp);

To Change state, simply do:

this.props.setState