mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 07:09:55 +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);
|
||
|
}
|