0.0.2 • Published 5 years ago

@bryandbor/map-selectors-to-props v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@bryandbor/map-selectors-to-props

Map Redux selectors to props

NPM JavaScript Style Guide

Install

npm install --save @bryandbor/map-selectors-to-props

Usage

// selectors.js
export const getUser = state => state.user || {};

export const getUserName = state => getUser(state).name || '';
export const getUserAge = state => getUser(state).age || 0;
import React from 'react';
import {mapSelectorsToProps} from '@bryandbor/map-selectors-to-props';

import {getUserName, getUserAge} from 'path/to/selectors.js';

const UserComponent = ({name, age}) => (
  <div>
    Hello, my name is {name}. I am {age} years old.
  </div>
);

export default mapSelectorsToProps({
  name: getUserName,
  age: getUserAge,
})(UserComponent);

License

MIT © bryandbor