@yomguithereal/react-utilities

1.2.3 • Public • Published

react-utilities

Installation

npm i --save @yomguithereal/react-utilities

Usage

measured

Higher-order component that will wait to be mounted before rendering its target now provided with width & height information.

Will also re-render the target on window resize.

import measured from '@yomguithereal/react-utilities/measured';

const MeasuredComponent = measured({width: '100%', height: '50px', debounce: 300}, Component);

// Using as decorator
@measured({width: '100%'})
class {
  render() {
    return (...);
  }
}

Fetcher

The Fetcher component aims at wrapping another component in order to fetch some JSON data for him before rendering it.

This is mainly useful when prototyping viz components.

import Fetcher from '@yomguithereal/react-utilities/Fetcher';

class Wrapper extends Component {
  render() {
    return (
      <Fetcher url="/data.json" reducer={x => x}>
        <DataViz />
      </Fetcher>
    );
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @yomguithereal/react-utilities

Weekly Downloads

1

Version

1.2.3

License

MIT

Last publish

Collaborators

  • yomguithereal