-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for higher order components with any arbitrary depth. #32
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8bcf60b
Add support for higher order components with any arbitrary depth.
8b9a8bb
Check if className equals the found argument.
b6beca3
Use already defined variable.
1b3dd75
Adjust hoc test for single hoc.
288f35b
Add test for multiple hoc stacked.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Component extends React.Component { | ||
render() { return null } | ||
} | ||
|
||
Component.propTypes = { | ||
children: React.PropTypes.string.isRequired, | ||
onClick: React.PropTypes.func, | ||
style: React.PropTypes.object, | ||
} | ||
|
||
export default withHoc()(deeperHoc(Component)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would you mind adding another test with just 1 hoc? it's a slightly different test case and I don't want this to regress in case someone refactors this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var Component = function (_React$Component) { | ||
_inherits(Component, _React$Component); | ||
|
||
function Component() { | ||
_classCallCheck(this, Component); | ||
|
||
return _possibleConstructorReturn(this, (Component.__proto__ || Object.getPrototypeOf(Component)).apply(this, arguments)); | ||
} | ||
|
||
_createClass(Component, [{ | ||
key: "render", | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
|
||
return Component; | ||
}(React.Component); | ||
|
||
Component.propTypes = { | ||
children: React.PropTypes.string.isRequired, | ||
onClick: React.PropTypes.func, | ||
style: React.PropTypes.object | ||
}; | ||
|
||
exports.default = withHoc()(deeperHoc(Component)); | ||
Component.__docgenInfo = { | ||
"description": "", | ||
"props": { | ||
"children": { | ||
"type": { | ||
"name": "custom", | ||
"raw": "React.PropTypes.string.isRequired" | ||
}, | ||
"required": false, | ||
"description": "" | ||
}, | ||
"onClick": { | ||
"type": { | ||
"name": "custom", | ||
"raw": "React.PropTypes.func" | ||
}, | ||
"required": false, | ||
"description": "" | ||
}, | ||
"style": { | ||
"type": { | ||
"name": "custom", | ||
"raw": "React.PropTypes.object" | ||
}, | ||
"required": false, | ||
"description": "" | ||
} | ||
} | ||
}; | ||
|
||
if (typeof STORYBOOK_REACT_CLASSES !== "undefined") { | ||
STORYBOOK_REACT_CLASSES["test/fixtures/hoc/actual.js"] = { | ||
name: "Component", | ||
docgenInfo: Component.__docgenInfo, | ||
path: "test/fixtures/hoc/actual.js" | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add some comments in here like
/* comment */
like the other files so we can make sure those are extracted properly?