@bryandbor/map-selectors-to-props
Map Redux selectors to props
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