hoc()() Higher Order Component Interface

February 14, 2018 ยท View on GitHub

The hoc()() function creates HOCs that can style HTML elements.

Usage

First import hoc().

import hoc from 'freestyler/lib/react/hoc';

Now let's create a HOC that will add orange border to HTML elements.

const withOrangeBorder = hoc({
    border: '1px solid orange'
});

const DivWithRedBorder = withOrangeBorder('div');

<DivWithRedBorder>Hello world</DivWithRedBorder>