mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-30 20:38:45 +08:00
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);
|
||
|
}
|