Skip to content

Commit

Permalink
Fix text rendering on React 15
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 5, 2018
1 parent 1e731ff commit 7cddebf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,12 @@

All notable changes will be documented in this file.

## 4.0.2 - 2018-10-05

### Fixes

* Fix text rendering in React versions lower than or equal to 15 (Espen Hovlandsdal)

## 4.0.1 - 2018-10-03

### Fixes
Expand Down
6 changes: 5 additions & 1 deletion src/renderers.js
Expand Up @@ -3,6 +3,8 @@

const xtend = require('xtend')
const React = require('react')

const supportsStringRender = parseInt((React.version || '16').slice(0, 2), 10) >= 16
const createElement = React.createElement

module.exports = {
Expand Down Expand Up @@ -37,7 +39,9 @@ module.exports = {
}

function TextRenderer(props) {
return props.children
return supportsStringRender
? props.children
: createElement('span', null, props.children)
}

function Root(props) {
Expand Down

0 comments on commit 7cddebf

Please sign in to comment.