excludeIf now returns a new component

This commit is contained in:
Chi Vinh Le
2017-09-29 23:33:37 +07:00
parent 90470b8331
commit 9bd55b267e
+19 -4
View File
@@ -1,4 +1,19 @@
export default (condition) => (BaseComponent) => {
BaseComponent.isExcluded = condition;
return BaseComponent;
};
import React from 'react';
import hoistStatics from 'recompose/hoistStatics';
/**
* ExcludeIf provides a property `emit: (eventName, value)`
* to the wrapped component.
*/
export default (condition) => hoistStatics((WrappedComponent) => {
class ExcludeIf extends React.Component {
render() {
return <WrappedComponent
{...this.props}
/>;
}
}
WrappedComponent.isExcluded = condition;
return ExcludeIf;
});