getTextFromChildren

Function that can be used to extract text content from React children.

Import

import { getTextFromChildren } from '@contentful/f36-utils';

Examples

Basic usage

const text = getTextFromChildren(<div>Hello world</div>);
console.log(text);
// "Hello world"
const text = getTextFromChildren(
<div>
Status: <EntityStatusBadge entityStatusType="draft" />
</div>,
);
console.log(text);
// "Status: Draft"

Help improve this page