mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
excludeIf now returns a new component
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user