UNPKG

2.33 kBMarkdownView Raw
1# hoist-non-react-statics
2
3[![NPM version](https://badge.fury.io/js/hoist-non-react-statics.svg)](http://badge.fury.io/js/hoist-non-react-statics)
4[![Build Status](https://img.shields.io/travis/mridgway/hoist-non-react-statics.svg)](https://travis-ci.org/mridgway/hoist-non-react-statics)
5[![Coverage Status](https://img.shields.io/coveralls/mridgway/hoist-non-react-statics.svg)](https://coveralls.io/r/mridgway/hoist-non-react-statics?branch=master)
6[![Dependency Status](https://img.shields.io/david/mridgway/hoist-non-react-statics.svg)](https://david-dm.org/mridgway/hoist-non-react-statics)
7[![devDependency Status](https://img.shields.io/david/dev/mridgway/hoist-non-react-statics.svg)](https://david-dm.org/mridgway/hoist-non-react-statics#info=devDependencies)
8
9Copies non-react specific statics from a child component to a parent component.
10Similar to `Object.assign`, but with React static keywords blacklisted from
11being overridden.
12
13```bash
14$ npm install --save hoist-non-react-statics
15```
16
17## Usage
18
19```js
20import hoistNonReactStatics from 'hoist-non-react-statics';
21
22hoistNonReactStatics(targetComponent, sourceComponent);
23```
24
25If you have specific statics that you don't want to be hoisted, you can also pass a third parameter to exclude them:
26
27```js
28hoistNonReactStatics(targetComponent, sourceComponent, { myStatic: true, myOtherStatic: true });
29```
30
31## What does this module do?
32
33See this [explanation](https://facebook.github.io/react/docs/higher-order-components.html#static-methods-must-be-copied-over) from the React docs.
34
35## Compatible React Versions
36
37| Compatible React Version | hoist-non-react-statics Version |
38|--------------------------|-------------------------------|
39| 16.3+ | >= 2.5.0 |
40| 0.13-16.2 | >= 1.0.0 |
41
42## Browser Support
43
44This package uses `Object.defineProperty` which has a broken implementation in IE8. In order to use this package in IE8, you will need a polyfill that fixes this method.
45
46## License
47This software is free to use under the Yahoo Inc. BSD license.
48See the [LICENSE file][] for license text and copyright information.
49
50[LICENSE file]: https://github.com/mridgway/hoist-non-react-statics/blob/master/LICENSE.md
51
52Third-party open source code used are listed in our [package.json file]( https://github.com/mridgway/hoist-non-react-statics/blob/master/package.json).