diff --git a/docs/api/ReactWrapper/renderProp.md b/docs/api/ReactWrapper/renderProp.md
index 5d8ffb418..e5585f175 100644
--- a/docs/api/ReactWrapper/renderProp.md
+++ b/docs/api/ReactWrapper/renderProp.md
@@ -1,7 +1,6 @@
-# `.renderProp(propName, ...args) => ReactWrapper`
+# `.renderProp(propName)(...args) => ReactWrapper`
-Calls the current wrapper's property with name `propName` and the `args` provided.
-Returns the result in a new wrapper.
+Returns a function that, when called with arguments `args`, will return a new wrapper based on the render prop in the original wrapper's prop `propName`.
NOTE: can only be called on wrapper of a single non-DOM component element node.
@@ -69,7 +68,7 @@ const App = () => (
```jsx
const wrapper = mount()
.find(Mouse)
- .renderProp('render');
+ .renderProp('render')();
expect(wrapper.equals(
The mouse position is 0, 0
)).to.equal(true);
```
@@ -79,7 +78,7 @@ expect(wrapper.equals(The mouse position is 0, 0
)).to.equal(true);
```jsx
const wrapper = mount()
.find(Mouse)
- .renderProp('render', 10, 20);
+ .renderProp('render')(10, 20);
expect(wrapper.equals(The mouse position is 10, 20
)).to.equal(true);
```
diff --git a/docs/api/ShallowWrapper/renderProp.md b/docs/api/ShallowWrapper/renderProp.md
index 6d8c76965..4a32d5636 100644
--- a/docs/api/ShallowWrapper/renderProp.md
+++ b/docs/api/ShallowWrapper/renderProp.md
@@ -1,7 +1,6 @@
-# `.renderProp(propName, ...args) => ShallowWrapper`
+# `.renderProp(propName)(...args) => ShallowWrapper`
-Calls the current wrapper's property with name `propName` and the `args` provided.
-Returns the result in a new wrapper.
+Returns a function that, when called with arguments `args`, will return a new wrapper based on the render prop in the original wrapper's prop `propName`.
NOTE: can only be called on wrapper of a single non-DOM component element node.
@@ -69,7 +68,7 @@ const App = () => (
```jsx
const wrapper = shallow()
.find(Mouse)
- .renderProp('render');
+ .renderProp('render')();
expect(wrapper.equals(The mouse position is 0, 0
)).to.equal(true);
```
@@ -79,7 +78,7 @@ expect(wrapper.equals(The mouse position is 0, 0
)).to.equal(true);
```jsx
const wrapper = shallow()
.find(Mouse)
- .renderProp('render', 10, 20);
+ .renderProp('render')(10, 20);
expect(wrapper.equals(The mouse position is 10, 20
)).to.equal(true);
```
diff --git a/docs/api/mount.md b/docs/api/mount.md
index fb4853e3a..adb967035 100644
--- a/docs/api/mount.md
+++ b/docs/api/mount.md
@@ -120,7 +120,7 @@ Get a wrapper with the first ancestor of the current node to match the provided
#### [`.render() => CheerioWrapper`](ReactWrapper/render.md)
Returns a CheerioWrapper of the current node's subtree.
-#### [`.renderProp(key) => ReactWrapper`](ReactWrapper/renderProp.md)
+#### [`.renderProp(key)() => ReactWrapper`](ReactWrapper/renderProp.md)
Returns a wrapper of the node rendered by the provided render prop.
#### [`.text() => String`](ReactWrapper/text.md)
diff --git a/docs/api/shallow.md b/docs/api/shallow.md
index 8cdab0071..7fd47d65a 100644
--- a/docs/api/shallow.md
+++ b/docs/api/shallow.md
@@ -130,7 +130,7 @@ Shallow renders the current node and returns a shallow wrapper around it.
#### [`.render() => CheerioWrapper`](ShallowWrapper/render.md)
Returns a CheerioWrapper of the current node's subtree.
-#### [`.renderProp(key) => ShallowWrapper`](ShallowWrapper/renderProp.md)
+#### [`.renderProp(key)() => ShallowWrapper`](ShallowWrapper/renderProp.md)
Returns a wrapper of the node rendered by the provided render prop.
#### [`.unmount() => ShallowWrapper`](ShallowWrapper/unmount.md)
diff --git a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
index 9bed5d92b..04032bf08 100644
--- a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
+++ b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
@@ -4974,17 +4974,17 @@ describeWithDOM('mount', () => {
}
const wrapperA = mount();
- const renderPropWrapperA = wrapperA.find(Bar).renderProp('render');
+ const renderPropWrapperA = wrapperA.find(Bar).renderProp('render')();
expect(renderPropWrapperA.find(Foo)).to.have.lengthOf(1);
const wrapperB = mount( } />
);
- const renderPropWrapperB = wrapperB.find(Bar).renderProp('render');
+ const renderPropWrapperB = wrapperB.find(Bar).renderProp('render')();
expect(renderPropWrapperB.find(Foo)).to.have.lengthOf(1);
const stub = sinon.stub().returns();
const wrapperC = mount(
);
stub.resetHistory();
- wrapperC.find(Bar).renderProp('render', 'one', 'two');
+ wrapperC.find(Bar).renderProp('render')('one', 'two');
expect(stub.args).to.deep.equal([['one', 'two']]);
});
diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
index 8e3aa0d80..223148b91 100644
--- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
+++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
@@ -4758,17 +4758,17 @@ describe('shallow', () => {
}
const wrapperA = shallow();
- const renderPropWrapperA = wrapperA.find(Bar).renderProp('render');
+ const renderPropWrapperA = wrapperA.find(Bar).renderProp('render')();
expect(renderPropWrapperA.find(Foo)).to.have.lengthOf(1);
const wrapperB = shallow( } />
);
- const renderPropWrapperB = wrapperB.find(Bar).renderProp('render');
+ const renderPropWrapperB = wrapperB.find(Bar).renderProp('render')();
expect(renderPropWrapperB.find(Foo)).to.have.lengthOf(1);
const stub = sinon.stub().returns();
const wrapperC = shallow(
);
stub.resetHistory();
- wrapperC.find(Bar).renderProp('render', 'one', 'two');
+ wrapperC.find(Bar).renderProp('render')('one', 'two');
expect(stub.args).to.deep.equal([['one', 'two']]);
});
diff --git a/packages/enzyme/src/ReactWrapper.js b/packages/enzyme/src/ReactWrapper.js
index dd5e67d59..47cd79af4 100644
--- a/packages/enzyme/src/ReactWrapper.js
+++ b/packages/enzyme/src/ReactWrapper.js
@@ -784,9 +784,9 @@ class ReactWrapper {
* Returns a wrapper of the node rendered by the provided render prop.
*
* @param {String} propName
- * @returns {ReactWrapper}
+ * @returns {Function}
*/
- renderProp(propName, ...args) {
+ renderProp(propName) {
const adapter = getAdapter(this[OPTIONS]);
if (typeof adapter.wrap !== 'function') {
throw new RangeError('your adapter does not support `wrap`. Try upgrading it!');
@@ -808,9 +808,11 @@ class ReactWrapper {
throw new TypeError(`expected prop “${propName}“ to contain a function, but it holds “${typeof prop}“`);
}
- const element = propValue(...args);
- const wrapped = adapter.wrap(element);
- return this.wrap(wrapped, null, this[OPTIONS]);
+ return (...args) => {
+ const element = propValue(...args);
+ const wrapped = adapter.wrap(element);
+ return this.wrap(wrapped, null, this[OPTIONS]);
+ };
});
}
diff --git a/packages/enzyme/src/ShallowWrapper.js b/packages/enzyme/src/ShallowWrapper.js
index 60d1c8c08..86fc4b423 100644
--- a/packages/enzyme/src/ShallowWrapper.js
+++ b/packages/enzyme/src/ShallowWrapper.js
@@ -1038,9 +1038,9 @@ class ShallowWrapper {
* Returns a wrapper of the node rendered by the provided render prop.
*
* @param {String} propName
- * @returns {ShallowWrapper}
+ * @returns {Function}
*/
- renderProp(propName, ...args) {
+ renderProp(propName) {
const adapter = getAdapter(this[OPTIONS]);
if (typeof adapter.wrap !== 'function') {
throw new RangeError('your adapter does not support `wrap`. Try upgrading it!');
@@ -1062,9 +1062,11 @@ class ShallowWrapper {
throw new TypeError(`expected prop “${propName}“ to contain a function, but it holds “${typeof prop}“`);
}
- const element = propValue(...args);
- const wrapped = adapter.wrap(element);
- return this.wrap(wrapped, null, this[OPTIONS]);
+ return (...args) => {
+ const element = propValue(...args);
+ const wrapped = adapter.wrap(element);
+ return this.wrap(wrapped, null, this[OPTIONS]);
+ };
});
}