mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-10 02:55:41 +00:00
da93fb1684
* Add repo wide prettier command to prepush * Make config file explict, remove formatAll to prepush
26 lines
662 B
TypeScript
26 lines
662 B
TypeScript
import React, { Component } from 'react';
|
|
|
|
interface RequiredProps {
|
|
condition: boolean;
|
|
conditionalProps: {
|
|
[key: string]: any;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Optional
|
|
*/
|
|
export const withConditional = <WrappedComponentProps extends {}>(
|
|
PassedComponent: React.ComponentType<WrappedComponentProps>
|
|
) =>
|
|
class extends Component<WrappedComponentProps & RequiredProps, {}> {
|
|
public render() {
|
|
const { condition, conditionalProps, ...passedProps } = this.props as any;
|
|
return condition ? (
|
|
<PassedComponent {...{ ...passedProps, ...(conditionalProps as object) }} />
|
|
) : (
|
|
<PassedComponent {...passedProps} />
|
|
);
|
|
}
|
|
};
|