react-hoc

0.1.8 • Public • Published

react-hoc

a higher order component creator helper

reactHOC :: (Enhancer, enhancerDisplayName) => Enhancer

hoc is a higher order enhancer : it take one enhancer and return one enhancer.

it does 3 things :

Installation

npm install --save react-hoc

Usage

example with a very basic hoc :

import React from 'react';
import reactHOC from 'react-hoc';
 
import Dummy from './Dummy';
 
const withColor = color => reactHOC(WrappedComponent => props => {
    return <WrappedComponent color={color} {...props} />
}, color);
const withBlue = withColor('blue');
const BlueComponent = withBlue(Dummy);
BlueComponent.displayName // => "blue(Dummy)"

if reactHOC enhancerDisplayName parameter is missing, Hoc() will be used.

const noColor = withColor();
const Test = noColor(Dummy);
Test.displayName // => "Hoc(Dummy)"

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.85latest
0.2.0-31next

Version History

VersionDownloads (Last 7 Days)Published
0.2.0-31
0.1.85
0.2.0-21
0.2.0-11
0.2.0-01
0.1.71
0.1.61
0.1.51
0.1.41
0.1.31
0.1.20
0.1.10
0.1.00

Package Sidebar

Install

npm i react-hoc

Weekly Downloads

14

Version

0.1.8

License

MIT

Last publish

Collaborators

  • trapcodien