0.0.3 • Published 7 years ago

react-simple-ctx-store v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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 => ({c : state.myStore.counter})}>
      {({ c }, { increaseCounter }) => {
        return (
          <button onClick={increaseCounter}>
            Add 1 to {c}
          </button>
        )
      }}
  </Connect>
</Provider>
);

ReactDOM.render(<App />, document.getElementById('root'));
0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago