Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rwu823/react-addons-text-content
Like DOM API `Node.textContent`
https://github.com/rwu823/react-addons-text-content
addons content react text
Last synced: about 1 month ago
JSON representation
Like DOM API `Node.textContent`
- Host: GitHub
- URL: https://github.com/rwu823/react-addons-text-content
- Owner: rwu823
- Created: 2016-06-02T05:55:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T20:34:12.000Z (about 1 year ago)
- Last Synced: 2024-09-20T10:08:57.249Z (3 months ago)
- Topics: addons, content, react, text
- Language: JavaScript
- Homepage: https://github.com/rwu823/react-addons-text-content
- Size: 5.86 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![version](https://img.shields.io/npm/v/react-addons-text-content.svg?label=version)](https://www.npmjs.org/package/react-addons-text-content) [![Build Status](https://img.shields.io/travis/rwu823/react-addons-text-content.svg?branch=master)](https://travis-ci.org/rwu823/react-addons-text-content/) [![Coverage](https://img.shields.io/coveralls/rwu823/react-addons-text-content.svg)](https://coveralls.io/github/rwu823/react-addons-text-content)
# react-addons-text-content
Like DOM API's `Node.textContent` and it works in React Element
## Install
```sh
$ npm install --save react-addons-text-content
```## Usage
```javascript
import textContent from 'react-addons-text-content'
render() {
const {children} = this.props
const text = textContent(children)
return (...)
}
```## Examples
```javascript
test('should be got text `Hello World`', assert => {
const Com =
Hello
World
assert.is(textContent(Com), `Hello World`)
})
``````javascript
test('array children', assert => {
const Com = (
Hello
World
{
['a',b
]
}
)
assert.is(textContent(Com), `Hello Worldab`)
})
``````javascript
test('array component', assert => {
const Com = (
[
a
, 'b', 'c',
x
y
]
)assert.is(textContent(Com), `abcxy`)
})
```## API
### textContent([React Element])