Skip to content

Commit

Permalink
feat(components/layouts): 透出Layout的ref,使它可以外部赋予ref
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed Jun 8, 2023
1 parent 98b8862 commit e2658b0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/components/src/layouts/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import { getClassNames } from '@tool-pack/basic';
import { BaseLayoutsProps } from './layout.types';

const rootClass = getComponentClass('layout');
export const Layout: React.FC<
export const Layout = React.forwardRef<
HTMLElement,
BaseLayoutsProps & {
vertical?: boolean;
}
> = (props) => {
>((props, ref) => {
const { vertical, className, children, ...rest } = props;
return (
<section
{...rest}
ref={ref}
className={getClassNames(rootClass, {
vertical,
[className as string]: className,
})}>
{children}
</section>
);
};
});

0 comments on commit e2658b0

Please sign in to comment.