@bryandbor/map-selectors-to-props

0.0.2 • Public • Published

@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

Package Sidebar

Install

npm i @bryandbor/map-selectors-to-props

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

8.46 kB

Total Files

6

Last publish

Collaborators

  • bryandbor