Skip to content

Commit

Permalink
apply HoistNonReactStatics, update pkg.json
Browse files Browse the repository at this point in the history
  • Loading branch information
kaesonho committed May 29, 2015
1 parent 5ebb104 commit 9f85b6a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ node_js:
- "iojs"
- "0.13"
- "0.12"
- "0.10"
after_success:
- "npm run func"
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In most cases, you will have to manually add the code to what you want to track,

Moreover, we provide a mechanism to build the `instrumentation tree`, typically you might have to manage the `instrumentation model data` you want and send out beacons separately, by using `react-i13n`, you have a better way to manage beacon data with an inheritance architecture, refer to [integrate with components](./docs/guides/integrateWithComponents.md) to see how do we get the benifit of `react-i13n`.

It's originated from [Rafael Martins](http://www.slideshare.net/RafaelMartins21/instrumentation-talk-39547608). More implement detail please refer to [Main Ideas](./docs/guides/mainIdeas.md) section.
It's originated from [Rafael Martins](http://www.slideshare.net/RafaelMartins21/instrumentation-talk-39547608). More implement detail please refer to [Main Ideas](#main-ideas) section.

## Features

Expand Down Expand Up @@ -72,6 +72,9 @@ var I13nDempApp = setupI13n(DemoApp, {
// then you could use I13nDemoApp to render you app
```

## Available Plugins
* [react-i13n-ga](https://github.com/kaesonho/react-i13n-ga) - Google Analytics plugin

## Test

### Unit
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
},
"scripts": {
"cover": "grunt cover",
"func": "./test/functional/saucelabs.sh",
"func": "./tests/functional/saucelabs.sh",
"lint": "jshint",
"test": "grunt unit"
},
"dependencies": {
"async": "^0.9.0",
"debug": "^2.1.3",
"eventemitter3": "^0.1.6",
"hoist-non-react-statics": "^1.0.0",
"object-assign": "^2.0.0",
"setimmediate": "^1.0.2"
},
Expand Down Expand Up @@ -47,8 +48,8 @@
},
"keywords": [
"react",
"component",
"reactors"
"i13n",
"instrumentation"
],
"peerDependencies": {
"react": "<= 0.13.x"
Expand Down
27 changes: 7 additions & 20 deletions src/utils/createI13nNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
var React = require('react');
var I13nMixin = require('../mixins/I13nMixin');
var objectAssign = require('object-assign');
var STATIC_CLONE_BLACK_LIST = [
'childContextTypes',
'contextTypes',
'displayName',
'getDefaultProps',
'isReactLegacyFactory',
'propTypes',
'type'
];
var hoistNonReactStatics = require('hoist-non-react-statics');

/**
* createI13nNode higher order function to create a Component with I13nNode functionality
Expand All @@ -24,19 +16,9 @@ var STATIC_CLONE_BLACK_LIST = [
*/
module.exports = function createI13nNode (Component, options) {
var componentName = Component.displayName || Component.name || Component;
var staticsObject = {};
options = options || {};

if ('function' === typeof Component) {
// clone the all the static functions except the black list
Object.keys(Component).forEach(function cloneStaticProperty (key) {
if (Component.hasOwnProperty(key) && -1 === STATIC_CLONE_BLACK_LIST.indexOf(key)) {
staticsObject[key] = Component[key];
}
});
}

var I13nComponent = React.createClass(objectAssign({}, I13nMixin, {statics: staticsObject}, {
var I13nComponent = React.createClass(objectAssign({}, I13nMixin, {
displayName: 'I13n' + componentName,

/**
Expand Down Expand Up @@ -79,5 +61,10 @@ module.exports = function createI13nNode (Component, options) {
);
}
}));

if ('function' === typeof Component) {
hoistNonReactStatics(I13nComponent, Component);
}

return I13nComponent;
};
File renamed without changes.

0 comments on commit 9f85b6a

Please sign in to comment.