mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
Add onDecorated property to decorated components (#1680)
This commit is contained in:
parent
6f2a77f655
commit
7a64c9ee8a
1 changed files with 19 additions and 1 deletions
|
|
@ -370,9 +370,27 @@ export const middleware = store => next => action => {
|
|||
nextMiddleware(middlewares)(action);
|
||||
};
|
||||
|
||||
// expose decorated component instance to the higher-order components
|
||||
function exposeDecorated(Component) {
|
||||
return class extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this.onRef = this.onRef.bind(this);
|
||||
}
|
||||
onRef(decorated) {
|
||||
if (this.props.onDecorated) {
|
||||
this.props.onDecorated(decorated);
|
||||
}
|
||||
}
|
||||
render() {
|
||||
return React.createElement(Component, Object.assign({}, this.props, {ref: this.onRef}));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getDecorated(parent, name) {
|
||||
if (!decorated[name]) {
|
||||
let class_ = parent;
|
||||
let class_ = exposeDecorated(parent);
|
||||
|
||||
modules.forEach(mod => {
|
||||
const method = 'decorate' + name;
|
||||
|
|
|
|||
Loading…
Reference in a new issue