mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 22:48:29 +08:00
7f9aff2cfb
* enhance: auto layout hasSider * test: update snapshot
23 lines
444 B
TypeScript
23 lines
444 B
TypeScript
import type * as React from 'react';
|
|
import toArray from 'rc-util/lib/Children/toArray';
|
|
|
|
import Sider from '../Sider';
|
|
|
|
export default function useHasSider(
|
|
siders: string[],
|
|
children?: React.ReactNode,
|
|
hasSider?: boolean,
|
|
) {
|
|
if (typeof hasSider === 'boolean') {
|
|
return hasSider;
|
|
}
|
|
|
|
if (siders.length) {
|
|
return true;
|
|
}
|
|
|
|
const childNodes = toArray(children);
|
|
|
|
return childNodes.some((node) => node.type === Sider);
|
|
}
|