Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ReactShallowRenderer.render returns the rendered output #5411

Merged
merged 1 commit into from
Nov 20, 2015

Conversation

simonewebdesign
Copy link
Contributor

I think would be nice to be able to chain functions this way:

let {props} = shallowRenderer.render(<MyComponent {...props} />).getRenderOutput();

This is not possible at the moment, as render() doesn't return itself, so I have to do it in two lines:

shallowRenderer.render(<MyComponent {...props} />);
let {props} = shallowRenderer.getRenderOutput();

@zpao
Copy link
Member

zpao commented Nov 6, 2015

I don't think we have any chaining APIs at the moment and I'm not sure it's worth the inconsistency to add one now. cc @spicyj @sebmarkbage who have more knowledge on the shallow renderer

@sebmarkbage
Copy link
Collaborator

Maybe render should just return the getRenderOutput?

cc @graue that might remember why we didn't.

@zpao
Copy link
Member

zpao commented Nov 6, 2015

cc @sebmarkbage who merged #4918 which added getRenderOutput (with relatedish discussion in #4056)

@sophiebits
Copy link
Collaborator

cc @zpao who commented twice on this issue

@zpao
Copy link
Member

zpao commented Nov 7, 2015

We have fun 😂 (sorry to distract from the main reason we're all here, which is to review this pull request)

@sebmarkbage
Copy link
Collaborator

cc @zpao who didn't realize that #4918 added getMountedInstance and not getRenderOutput which was added in #2497.

@simonewebdesign Would you prefer if it just returned getRenderOutput immediately since that seems more convenient for your use case and it's probably fairly common?

@facebook-github-bot
Copy link

@simonewebdesign updated the pull request.

@simonewebdesign
Copy link
Contributor Author

@sebmarkbage I agree on that, the API would be more straightforward.

@simonewebdesign simonewebdesign changed the title ReactShallowRenderer.render returns itself ReactShallowRenderer.render returns the rendered output Nov 8, 2015
@hartzis
Copy link
Contributor

hartzis commented Nov 9, 2015

Definitely like this change! @jsdf and @glenjamin either of you have concerns on this and how it could effect shallow rendering testing libraries?

@glenjamin
Copy link
Contributor

Seems safe enough to me, as mentioned this should be the most common case.

sebmarkbage added a commit that referenced this pull request Nov 20, 2015
ReactShallowRenderer.render returns the rendered output
@sebmarkbage sebmarkbage merged commit 64f795e into facebook:master Nov 20, 2015
@zpao
Copy link
Member

zpao commented Nov 20, 2015

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants