react-addons-text-content

WebJar for react-addons-text-content

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

react-addons-text-content
Last Version

Last Version

0.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

react-addons-text-content
WebJar for react-addons-text-content
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/rwu823/react-addons-text-content

Download react-addons-text-content

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/react-addons-text-content/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>react-addons-text-content</artifactId>
    <version>0.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/react-addons-text-content/
implementation 'org.webjars.npm:react-addons-text-content:0.0.4'
// https://jarcasting.com/artifacts/org.webjars.npm/react-addons-text-content/
implementation ("org.webjars.npm:react-addons-text-content:0.0.4")
'org.webjars.npm:react-addons-text-content:jar:0.0.4'
<dependency org="org.webjars.npm" name="react-addons-text-content" rev="0.0.4">
  <artifact name="react-addons-text-content" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='react-addons-text-content', version='0.0.4')
)
libraryDependencies += "org.webjars.npm" % "react-addons-text-content" % "0.0.4"
[org.webjars.npm/react-addons-text-content "0.0.4"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

version Build Status Coverage

react-addons-text-content

Like DOM API's Node.textContent and it works in React Element

Install

$ npm install --save react-addons-text-content

Usage

import textContent from 'react-addons-text-content'
 
render() {
  const {children} = this.props
  const text = textContent(children)
  
  return (...)
}

Examples

test('should be got text `Hello World`', assert => {
  const Com =
      <div>
        <h1>Hello</h1> World
      </div>

  assert.is(textContent(Com), `Hello World`)
})
test('array children', assert => {
  const Com = (
    <div>
      <h1>Hello</h1> World
      {
        ['a', <h2>b</h2>]
      }
    </div>
  )
  
  assert.is(textContent(Com), `Hello Worldab`)
})
test('array component', assert => {
  const Com = (
    [
      <h1>a</h1>, 'b', 'c',
      <div>
        <h2>x</h2>y
      </div>
    ]
  )

  assert.is(textContent(Com), `abcxy`)
})

API

textContent([React Element])

Versions

Version
0.0.4