react-simple-ctx-store

0.0.3 • Public • Published

Simple React Context Store

Based on store objects and actions, draws part of concept from redux but it's much more simpler and more pleasant to use :)

README in progress!

installation:

npm i -P react-simple-ctx-store

Some examples:

import React, { Component } from 'react';
import { createStore, combineStores } from './createStore';
 
const store = combineStores({
  name: 'myStore',
  state : {
    counter: 0
  },
  actions : {
    increaseCounter({state}){
      return { counter: state.myStore.counter + 1 };
    }
  }
})
 
const {
  Provider,
  Connect,
  connect 
= createStore(store);
 
const App = (
<Provider>
  <h2>My App</h2>
  <Connect select={state => ({: state.myStore.counter})}>
      {({ c }, { increaseCounter }) => {
        return (
          <button onClick={increaseCounter}>
            Add 1 to {c}
          </button>
        )
      }}
  </Connect>
</Provider>
);
 
ReactDOM.render(<App />, document.getElementById('root'));

Package Sidebar

Install

npm i react-simple-ctx-store

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

417 kB

Total Files

7

Last publish

Collaborators

  • _dawiidio