Skip to content

Instantly share code, notes, and snippets.

@LucaColonnello
Last active August 29, 2015 14:27
Show Gist options
  • Save LucaColonnello/c3061d0e6900116ef903 to your computer and use it in GitHub Desktop.
Save LucaColonnello/c3061d0e6900116ef903 to your computer and use it in GitHub Desktop.
createComponent module for use with React shallow rendering
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