Revision fd35aadea725ec7562789237d1755d11dec38c8c authored by Nishan Bende on 14 October 2021, 12:48:08 UTC, committed by Nishan Bende on 14 October 2021, 12:48:08 UTC
1 parent ad23a35
component.tsx
import React from 'react';
import type { AnyStyledComponent } from 'styled-components';
import { usePropsWithComponentTheme } from '../hooks/useThemeProps/usePropsWithComponentTheme';
import type { ComponentTheme } from '../theme';
import type { FactoryComponentProps } from './types';
import { makeStyledComponent } from '../utils/styled';
export default function <P>(
Component: React.ComponentType<P>,
componentTheme?: ComponentTheme
) {
return React.forwardRef(
({ children, ...props }: P & FactoryComponentProps, ref: any) => {
const StyledComponent = makeStyledComponent(
Component as AnyStyledComponent
);
const calculatedProps = usePropsWithComponentTheme(componentTheme, props);
return (
<StyledComponent {...(calculatedProps as P)} ref={ref}>
{children}
</StyledComponent>
);
}
);
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...