
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
react-innertext
Advanced tools
Returns the innerText of a React JSX object, similar to the innerText property of DOM elements.
npm install react-innertext --save
oryarn add react-innertext
npm run test
oryarn test
const innerText = require('react-innertext');
innerText(
<div>
Hello <strong>world</strong>!
I am <span children={3} /> years old!
</div>
) // 'Hello world! I am 3 years old!'
import innerText from 'react-innertext';
innerText(
<div>
Hello <strong>world</strong>!
I am <span children={3} /> years old!
</div>
) // 'Hello world! I am 3 years old!'
In the below example, the title
attribute of the <th>
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
.
class MyTableHeaderCell extends React.PureComponent {
render() {
return (
<th
children={this.props.children}
title={innerText(this.props.children)}
/>
);
}
}
class MyTableHeader extends React.PureComponent {
render() {
return (
<thead>
<tr>
<MyTableHeaderCell>
<b>Username</b>
<SortButton />
</MyTableHeader>
</tr>
</thead>
);
}
}
FAQs
Returns the innerText of a React JSX object.
The npm package react-innertext receives a total of 294,620 weekly downloads. As such, react-innertext popularity was classified as popular.
We found that react-innertext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.