Skip to content

Commit a8e5327

Browse files
marcshillingMarc Shilling
andauthored
fix(withTheme): refs on functional components wrapped (react-native-elements#3708)
Co-authored-by: Marc Shilling <marc.shilling@stadiumgoods.com>
1 parent 96c8d45 commit a8e5327

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

packages/themed/src/config/withTheme.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ const ThemedComponent = (
4141
children,
4242
};
4343

44-
return isClassComponent(WrappedComponent) ? (
45-
<WrappedComponent ref={forwardedRef} {...newProps} />
46-
) : (
47-
<WrappedComponent {...newProps} />
48-
);
44+
return <WrappedComponent ref={forwardedRef} {...newProps} />;
4945
}
5046
const { components, ...restTheme } = theme;
5147
const themedProps =
@@ -64,10 +60,7 @@ const ThemedComponent = (
6460
children,
6561
};
6662

67-
if (isClassComponent(WrappedComponent)) {
68-
return <WrappedComponent ref={forwardedRef} {...newProps} />;
69-
}
70-
return <WrappedComponent {...newProps} />;
63+
return <WrappedComponent ref={forwardedRef} {...newProps} />;
7164
}}
7265
</ThemeConsumer>
7366
);
@@ -102,7 +95,7 @@ function withTheme<P = {}, T = {}>(
10295
return hoistNonReactStatics(React.forwardRef(Component), WrappedComponent);
10396
}
10497

105-
return Component;
98+
return React.forwardRef(Component);
10699
}
107100

108101
export default withTheme;

0 commit comments

Comments
 (0)