react-redux-values

1.1.2 • Public • Published

react-redux-values

npm License: BSD 3-clause "New" or "Revised" License standard-readme compliant

David David David

Get and Set values from a redux store in a declarative way

Table of Contents

Install

yarn add --dev react-redux-values

Usage

store.js:

import { reducer } from 'react-redux-values';
import { createStore, combineReducers } from 'redux';
 
export default createStore(
  combineReducers({
    values: reducer
  })
);

app.js:

import Value from 'react-redux-values';
 
export default () => (
  <Value name="hey" initialValue="oh">
    {({ value, onValueChange }) => (
      <p onClick={() => onValueChange('heyoh')}>{value}</p>
    )}
  </Value>
);

with-connect.js:

import Value, { set } from 'react-redux-values';
import { connect } from 'react-redux';
 
const Div = ({ handleClick }) => (
  <Value name="hey" initialValue="oh">
    {({ value }) => <p onClick={handleClick}>{value}</p>}
  </Value>
);
 
export default connect(null, dispatch => ({
  handleClick: () => dispatch(set({ name: 'hey', value: 'heyoh' }))
}))(Div);

License

BSD-3-Clause

Package Sidebar

Install

npm i react-redux-values

Weekly Downloads

0

Version

1.1.2

License

BSD-3-Clause

Last publish

Collaborators

  • ramitos