Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Docs say ReactComponent when it is actually ReactElement #24

Closed
aaronbeall opened this issue Feb 23, 2016 · 4 comments
Closed

Docs say ReactComponent when it is actually ReactElement #24

aaronbeall opened this issue Feb 23, 2016 · 4 comments

Comments

@aaronbeall
Copy link

Throughout the documentation and the source it refers to input as being a ReactComponent, but it actually is a ReactElement.

For example, the docs for findWithType show:

ReactComponent findWithType(ReactComponent tree, function componentClass | string tagName)

With the example:

const renderer = ReactTestUtils.createRenderer();

renderer.render(<MyComponent />);
expect(findWithType(renderer.getRenderOutput(), MyOtherComponent)).not.toThrow();

However, renderer.getRenderOutput() returns a ReactElement, not a ReactComponent.

I found this rather confusing, since the primary issue with ReactTestUtils when using ShallowRenderer is that the find/scry functions do not support searching a ReactElement, only a ReactComponent.

@sheepsteak
Copy link
Owner

Thanks for pointing this out. I completely missed it when updating the README recently. You're right, the first parameter to these functions should be ReactElement.

As for what is returned by getRenderOutput(), I was never actually sure what it was. The documentation is very short!

@aaronbeall
Copy link
Author

Yep I agree the documentation sure is lacking! I was able to figure most of this out by using TypeScript (react.d.ts definition file). I wrote a definition file for this library.

@sheepsteak
Copy link
Owner

Oh great! I don't use TypeScript myself but I understand it's definitions can be used with Flow. Is that right? I'll check it out, thanks.

@sheepsteak
Copy link
Owner

Looks like I was wrong but it might get implemented.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants