fix: wrap styled(component) in useMemo so it doesn't re-mount on every render (#69)

This commit is contained in:
Jay Meistrich
2022-06-02 07:28:52 +08:00
committed by Mark Lawlor
parent 6734e29aa8
commit cad293411d

View File

@@ -8,7 +8,7 @@ export type StyledComponentProps<P> = StyledProps<P> & {
export const StyledComponent = React.forwardRef(
({ component, ...options }, ref) => {
const Component = styled(component);
const Component = React.useMemo(() => styled(component), [component]);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return <Component {...(options as any)} ref={ref as any} />;
}