mirror of
https://github.com/zhigang1992/nativewind.git
synced 2026-06-15 10:17:54 +08:00
fix: wrap styled(component) in useMemo so it doesn't re-mount on every render (#69)
This commit is contained in:
committed by
Mark Lawlor
parent
6734e29aa8
commit
cad293411d
@@ -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} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user