--- layout: page --- # hasChildren() Returns true if the element has children, otherwise returns false. ```typescript hasChildren(child: ReactNode): boolean ``` ## Arguments
children
The children array from the element where is used.
## Return Value A `boolean` which is `true` if the element has children, but `false` if it doesn't. ## Examples ```jsx import React, { ReactElement, ReactNode } from 'react'; import { render } from 'react-dom'; import { hasChildren } from 'react-children-utilities'; interface Props { children?: ReactNode; } const Test = ({ children }: Props): ReactElement => (
{hasChildren(children) ? 'yes' : 'no'}
); const Example = (): ReactElement => this is the inner content; render(, document.body); // Result: //
yes
const Example2 = (): ReactElement => {null}; render(, document.body); // Result: //
no
```