Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Make renderNothing as a classComponent (#289)
Browse files Browse the repository at this point in the history
* Fixes #288

* Test on render null
  • Loading branch information
istarkov committed Dec 20, 2016
1 parent 1c3d2b3 commit 9af9095
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/packages/recompose/__tests__/renderNothing-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import test from 'ava'
import React from 'react'
import { renderNothing } from '../'
import { shallow } from 'enzyme'

test('renderNothing returns a component that renders null', t => {
const nothing = renderNothing('div')
t.is(nothing(), null)
t.is(nothing.displayName, 'Nothing')
const Nothing = renderNothing('div')
const wrapper = shallow(<Nothing />)
t.is(wrapper.type(), null)
t.is(Nothing.displayName, 'Nothing')
})
13 changes: 9 additions & 4 deletions src/packages/recompose/renderNothing.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Component } from 'react'
import createHelper from './createHelper'

const renderNothing = _ => {
const Nothing = () => null
Nothing.displayName = 'Nothing'
return Nothing
class Nothing extends Component {
render() {
return null
}
}

Nothing.displayName = 'Nothing'

const renderNothing = _ => Nothing

export default createHelper(renderNothing, 'renderNothing', false, true)

0 comments on commit 9af9095

Please sign in to comment.