0.1.8 • Published 7 years ago

react-hoc v0.1.8

Weekly downloads
305
License
MIT
Repository
github
Last release
7 years ago

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)"
0.2.0-3

7 years ago

0.1.8

7 years ago

0.2.0-2

7 years ago

0.2.0-1

7 years ago

0.2.0-0

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago