Returns the innerText of a React JSX object.
npm install react-innertextReturns the innerText of a React JSX object, similar to the innerText property
of DOM elements.
* npm install react-innertext or
* yarn add react-innertext
``JS`
import innerText from 'react-innertext';
innerText(
Hello world!
I am years old!
) // 'Hello world! I am 3 years old!'
`JS`
const innerText = require('react-innertext');
innerText(
Hello world!
I am years old!
) // 'Hello world! I am 3 years old!'
In the below example, the title attribute of the
element sanitizes the
children prop. This allows the children to contain HTML or other React
Elements, while providing a safe, plain text string for the title.`JS
function MyTableHeader() {
return (
Username
);
}// title="Username"
function MyTableHeaderCell({ children }) {
return (
children={children}
title={innerText(children)}
/>
);
}
``