Skip to content

Commit

Permalink
Return _instance if public instance is null (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
aweary authored and mathieuancelin committed May 8, 2016
1 parent a83f225 commit c250345
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ReactWrapperComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function createWrapperComponent(node, options = {}) {
const component = this._reactInternalInstance._renderedComponent;
const inst = component.getPublicInstance();
if (inst === null) {
return component;
return component._instance;
}
return inst;
},
Expand Down
9 changes: 9 additions & 0 deletions test/ReactWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ describeWithDOM('mount', () => {
expect(wrapper.find('.qoo').text()).to.equal('qux');
});

it('supports findDOMNode with stateless components', () => {
const Foo = ({ foo }) => (
<div>{foo}</div>
);

const wrapper = mount(<Foo foo="qux" />);
expect(wrapper.text()).to.equal('qux');
});

it('works with nested stateless', () => {
const TestItem = () => (
<div className="item">1</div>
Expand Down

0 comments on commit c250345

Please sign in to comment.