Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/renderComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function renderComponent<T>(
): React.Node {
const { render, children, component, ...rest } = props
if (component) {
return React.createElement(component, { ...rest, children }) // inject children back in
return React.createElement(component, { ...rest, children, render })
}
if (render) {
return render({ ...rest, children }) // inject children back in
Expand Down
16 changes: 16 additions & 0 deletions src/renderComponent.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import renderComponent from './renderComponent'

describe('renderComponent', () => {
it('should pass both render and children prop', () => {
const children = 'some children'
const render = () => 'examplary render function'
const props = {
component: () => null,
children,
render
}
const name = 'TestComponent'
const result = renderComponent(props, name)
expect(result.props).toEqual({ children, render })
})
})