Comparing version 0.10.3 to 0.10.4
{ | ||
"name": "marty-lib", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "A Javascript library for state management in React applications", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -70,3 +70,3 @@ var React = require('react'); | ||
describe('component lifestyle', () => { | ||
describe('component lifecycle', () => { | ||
var ParentComponent; | ||
@@ -280,3 +280,3 @@ var componentWillReceiveProps; | ||
describe('when the parent updates its props then it should update its childrens', () => { | ||
describe('when the parent updates its props then it should update its children\'s', () => { | ||
var ParentComponent, fetch; | ||
@@ -433,2 +433,8 @@ | ||
return [this, 'foo']; | ||
}, | ||
statics: { | ||
somethingElse() { | ||
return [this, 'bar']; | ||
} | ||
} | ||
@@ -443,2 +449,7 @@ }); | ||
}); | ||
it('should expose the static function on the component class', () => { | ||
expect(ContainerComponent.somethingElse()) | ||
.to.eql([ContainerComponent, 'bar']); | ||
}); | ||
}); | ||
@@ -677,2 +688,15 @@ | ||
describe('injectApp', () => { | ||
it('should inject app as a property on the component', () => { | ||
class Component extends React.Component { | ||
render() { | ||
return null; | ||
} | ||
} | ||
Marty.injectApp(Component); | ||
expect(render(Component).app).to.eql(app); | ||
}); | ||
}); | ||
function withoutApp(props) { | ||
@@ -679,0 +703,0 @@ return _.omit(props, 'app'); |
@@ -21,7 +21,17 @@ let _ = require('../mindash'); | ||
module.exports = function (React) { | ||
let DEFAULT_CONTEXT_TYPES = { | ||
app: React.PropTypes.object, | ||
const DEFAULT_CONTEXT_TYPES = { | ||
app: React.PropTypes.object | ||
}; | ||
return function createContainer(InnerComponent, config) { | ||
function injectApp(Component) { | ||
Component.contextTypes = _.extend( | ||
{}, | ||
DEFAULT_CONTEXT_TYPES, | ||
Component.contextTypes | ||
); | ||
appProperty(Component.prototype); | ||
} | ||
function createContainer(InnerComponent, config) { | ||
config = config || {}; | ||
@@ -41,10 +51,4 @@ | ||
InnerComponent.contextTypes = _.extend( | ||
{}, | ||
DEFAULT_CONTEXT_TYPES, | ||
InnerComponent.contextTypes | ||
); | ||
injectApp(InnerComponent); | ||
appProperty(InnerComponent.prototype); | ||
let specification = _.extend({ | ||
@@ -140,9 +144,12 @@ contextTypes: contextTypes, | ||
var Container = React.createClass(specification); | ||
const Container = React.createClass(specification); | ||
return _.extend( | ||
Container, | ||
config.statics, | ||
{ | ||
InnerComponent, | ||
displayName: `${innerComponentDisplayName}Container` | ||
} | ||
); | ||
Container.InnerComponent = InnerComponent; | ||
Container.displayName = innerComponentDisplayName + 'Container'; | ||
return Container; | ||
function callBoth(func1, func2) { | ||
@@ -169,3 +176,5 @@ if (_.isFunction(func2)) { | ||
} | ||
}; | ||
}; | ||
} | ||
return {injectApp, createContainer}; | ||
}; |
@@ -0,3 +1,5 @@ | ||
const _ = require('../mindash'); | ||
module.exports = function (marty, React) { | ||
marty.createContainer = require('./createContainer')(React); | ||
}; | ||
_.extend(marty, require('./createContainer')(React)); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
550176
15793