Last active
August 29, 2015 14:27
-
-
Save LucaColonnello/c3061d0e6900116ef903 to your computer and use it in GitHub Desktop.
createComponent module for use with React shallow rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react/addons'; | |
const TestUtils = React.addons.TestUtils; | |
export default createComponent; | |
function createComponent(component, props, ...children) { | |
const shallowRenderer = TestUtils.createRenderer(); | |
shallowRenderer.render(React.createElement(component, props, children.length > 1 ? children : children[0])); | |
return shallowRenderer.getRenderOutput(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment