Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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`

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])