Rename WrappedComponent to BaseComponent

This commit is contained in:
Chi Vinh Le
2018-07-17 19:22:06 -03:00
parent 9c98330ea4
commit d09835020d
4 changed files with 11 additions and 11 deletions
@@ -22,10 +22,10 @@ function createMutationContainer<T extends string, I, R>(
): InferableComponentEnhancer<{ [P in T]: (input: I) => Promise<R> }> {
return compose(
withContext(({ relayEnvironment }) => ({ relayEnvironment })),
hoistStatics((WrappedComponent: React.ComponentType<any>) => {
hoistStatics((BaseComponent: React.ComponentType<any>) => {
class CreateMutationContainer extends React.Component<any> {
public static displayName = wrapDisplayName(
WrappedComponent,
BaseComponent,
"createMutationContainer"
);
@@ -38,7 +38,7 @@ function createMutationContainer<T extends string, I, R>(
const inject = {
[propName]: this.commit,
};
return <WrappedComponent {...rest} {...inject} />;
return <BaseComponent {...rest} {...inject} />;
}
}
return CreateMutationContainer as React.ComponentType<any>;
@@ -34,7 +34,7 @@ function withLocalStateContainer<T>(
): InferableComponentEnhancer<{ local: T }> {
return compose(
withContext(({ relayEnvironment }) => ({ relayEnvironment })),
hoistStatics((WrappedComponent: React.ComponentType<any>) => {
hoistStatics((BaseComponent: React.ComponentType<any>) => {
class LocalStateContainer extends React.Component<Props, any> {
constructor(props: Props) {
super(props);
@@ -65,7 +65,7 @@ function withLocalStateContainer<T>(
public render() {
const { relayEnvironment: _, ...rest } = this.props;
return <WrappedComponent {...rest} local={this.state.data} />;
return <BaseComponent {...rest} local={this.state.data} />;
}
}
return LocalStateContainer as React.ComponentType<any>;
@@ -15,7 +15,7 @@ interface InjectedProps {
* or touch.
*/
const withKeyboardFocus = hoistStatics<InjectedProps>(
<T extends InjectedProps>(WrappedComponent: React.ComponentType<T>) => {
<T extends InjectedProps>(BaseComponent: React.ComponentType<T>) => {
class WithKeyboardFocus extends React.Component<any> {
public state = {
keyboardFocus: false,
@@ -48,7 +48,7 @@ const withKeyboardFocus = hoistStatics<InjectedProps>(
public render() {
return (
<WrappedComponent
<BaseComponent
{...this.props}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
@@ -65,5 +65,5 @@ const withKeyboardFocus = hoistStatics<InjectedProps>(
// TODO: workaround, add bug link.
export default withKeyboardFocus as <P extends Partial<InjectedProps>>(
WrappedComponent: React.ComponentType<P>
BaseComponent: React.ComponentType<P>
) => React.ComponentType<P>;
+3 -3
View File
@@ -15,7 +15,7 @@ interface InjectedProps {
* or touch.
*/
const withMouseHover = hoistStatics<InjectedProps>(
<T extends InjectedProps>(WrappedComponent: React.ComponentType<T>) => {
<T extends InjectedProps>(BaseComponent: React.ComponentType<T>) => {
class WithMouseHover extends React.Component<any> {
public state = {
mouseHover: false,
@@ -48,7 +48,7 @@ const withMouseHover = hoistStatics<InjectedProps>(
public render() {
return (
<WrappedComponent
<BaseComponent
{...this.props}
onMouseOver={this.handleMouseOver}
onMouseOut={this.handleMouseOut}
@@ -65,5 +65,5 @@ const withMouseHover = hoistStatics<InjectedProps>(
// TODO: workaround, add bug link.
export default withMouseHover as <P extends Partial<InjectedProps>>(
WrappedComponent: React.ComponentType<P>
BaseComponent: React.ComponentType<P>
) => React.ComponentType<P>;