Returns the inner text of react elements. This package was inspired with HTMLElement.innerText and Node.textContent web APIs and react-innertext npm package.
There is no native API in React to get the nested text content of react elements. This package provides a simple API to get the text content of nested elements (components)
To use this package, you only need to install this dependency, import it and invoke the getInnerText
function, e.g.:
const innerText = getInnerText(
<div>
<p>First paragraph.</p>
<p>Second paragraph</p>
</div>
)
console.log(innerText) // "First paragraph.Second paragraph"
npm install @lukaspolak/react-get-inner-text
or
yarn add @lukaspolak/react-get-inner-text
Please read the Contribution guidelines to start with your awesome contributions!
There are a lot of similar libraries/packages on GitHub and npm, that can do the same. I wanted to enhance my programming skills, and I didn't want to find a unique name for the package.