Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guillaumearm/react-hoc
a higher order component creator helper
https://github.com/guillaumearm/react-hoc
Last synced: about 2 months ago
JSON representation
a higher order component creator helper
- Host: GitHub
- URL: https://github.com/guillaumearm/react-hoc
- Owner: guillaumearm
- License: mit
- Created: 2016-11-14T21:02:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-15T18:15:23.000Z (about 8 years ago)
- Last Synced: 2024-09-21T12:09:19.793Z (3 months ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 :
- [hoist non react statics](https://www.npmjs.com/package/hoist-non-react-statics)
- hoist/set WrappedComponent property
- hoist/set displayName property### Installation
`npm install --save react-hoc`
### Usage
__example with a very basic hoc :__
```js
import React from 'react';
import reactHOC from 'react-hoc';import Dummy from './Dummy';
const withColor = color => reactHOC(WrappedComponent => props => {
return
}, color);
const withBlue = withColor('blue');
const BlueComponent = withBlue(Dummy);
BlueComponent.displayName // => "blue(Dummy)"
```
if `reactHOC` enhancerDisplayName parameter is missing, `Hoc()` will be used.
```js
const noColor = withColor();
const Test = noColor(Dummy);
Test.displayName // => "Hoc(Dummy)"
```