{"id":13727203,"url":"https://github.com/quisido/react-innertext","last_synced_at":"2025-03-28T22:30:51.720Z","repository":{"id":27764406,"uuid":"115147571","full_name":"quisido/react-innertext","owner":"quisido","description":"Returns the innerText of a React JSX object.","archived":false,"fork":false,"pushed_at":"2022-02-11T00:44:03.000Z","size":204,"stargazers_count":51,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T08:20:37.794Z","etag":null,"topics":["babel","babeljs","chai","es6","innerhtml","innertext","javascript","js","mocha","npm","npm-module","npm-package","react","reactjs","travis","travis-ci","travisci","webpack"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quisido.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-22T20:19:00.000Z","updated_at":"2024-10-23T23:12:32.000Z","dependencies_parsed_at":"2022-08-07T13:01:08.842Z","dependency_job_id":null,"html_url":"https://github.com/quisido/react-innertext","commit_stats":null,"previous_names":["charlesstover/jsx-inner-text","quisido/react-innertext","charlesstover/react-innertext"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quisido%2Freact-innertext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quisido%2Freact-innertext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quisido%2Freact-innertext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quisido%2Freact-innertext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quisido","download_url":"https://codeload.github.com/quisido/react-innertext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246109627,"owners_count":20724909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","babeljs","chai","es6","innerhtml","innertext","javascript","js","mocha","npm","npm-module","npm-package","react","reactjs","travis","travis-ci","travisci","webpack"],"created_at":"2024-08-03T01:03:44.002Z","updated_at":"2025-03-28T22:30:51.384Z","avatar_url":"https://github.com/quisido.png","language":"TypeScript","funding_links":["https://github.com/sponsors/CharlesStover"],"categories":["TypeScript"],"sub_categories":[],"readme":"# React innerText\n\n[![version](https://img.shields.io/npm/v/react-innertext.svg)](https://www.npmjs.com/package/react-innertext)\n[![minzipped size](https://img.shields.io/bundlephobia/minzip/react-innertext.svg)](https://www.npmjs.com/package/react-innertext)\n[![downloads](https://img.shields.io/npm/dt/react-innertext.svg)](https://www.npmjs.com/package/react-innertext)\n\nReturns the innerText of a React JSX object, similar to the innerText property\nof DOM elements.\n\n## Install\n\n* `npm install react-innertext` or\n* `yarn add react-innertext`\n\n## Use\n\n### Client-Side Rendering (ES6)\n\n```JS\nimport innerText from 'react-innertext';\ninnerText(\n  \u003cdiv\u003e\n    Hello \u003cstrong\u003eworld\u003c/strong\u003e!\n    I am \u003cspan children={3} /\u003e years old!\n  \u003c/div\u003e\n) // 'Hello world! I am 3 years old!'\n```\n\n### Server-Side Rendering (CommonJS)\n\n```JS\nconst innerText = require('react-innertext');\ninnerText(\n  \u003cdiv\u003e\n    Hello \u003cstrong\u003eworld\u003c/strong\u003e!\n    I am \u003cspan children={3} /\u003e years old!\n  \u003c/div\u003e\n) // 'Hello world! I am 3 years old!'\n```\n\n### Real World Example\n\nIn the below example, the `title` attribute of the `\u003cth\u003e` element sanitizes the\n`children` prop. This allows the children to contain HTML or other React\nElements, while providing a safe, plain text string for the `title`.\n\n```JS\nfunction MyTableHeader() {\n  return (\n    \u003cthead\u003e\n      \u003ctr\u003e\n        \u003cMyTableHeaderCell\u003e\n          \u003cb\u003eUsername\u003c/b\u003e\n          \u003cSortButton /\u003e\n        \u003c/MyTableHeaderCell\u003e\n      \u003c/tr\u003e\n    \u003c/thead\u003e\n  );\n}\n\n// title=\"Username\"\nfunction MyTableHeaderCell({ children }) {\n  return (\n    \u003cth\n      children={children}\n      title={innerText(children)}\n    /\u003e\n  );\n}\n```\n\n## Sponsor 💗\n\nIf you are a fan of this project, you may\n[become a sponsor](https://github.com/sponsors/CharlesStover)\nvia GitHub's Sponsors Program.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquisido%2Freact-innertext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquisido%2Freact-innertext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquisido%2Freact-innertext/lists"}