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

[Feature request] Allow MockedProvider to pass down props to child component #2470

Closed
miachenmtl opened this issue Oct 5, 2018 · 4 comments

Comments

@miachenmtl
Copy link
Contributor

My use case is testing a component using the Query component that changes in response to a change in props. The problem is enzyme's setProps only works on the root node, so since I have to wrap the component in MockedProvider, the props only change for MockedProvider, not the component itself. If MockedProvider passed down other props to its child component, like the React docs recommend for HOCs, testing would be easy.

I realize that there is a workaround in separating out the component rendered by Query and testing that, but that seems to defeat the purpose of using the render props pattern instead of the graphql HOC.

@JoviDeCroock
Copy link
Contributor

The purpose of the render props is that it shares props with the parent component, so in non-testing there's not really a benefit to this in my opinion.

@miachenmtl
Copy link
Contributor Author

I'm only suggesting a change to MockedProvider, so it's only supposed to be used in testing.

@miachenmtl
Copy link
Contributor Author

I put together a PR showing what I mean. I've never worked with TypeScript before, so I apologize for the clumsiness in the code, but the idea is there. #2482

@danilobuerger
Copy link
Contributor

Feature requests and non-bug related discussions are no longer managed in this repo. Feature requests should be opened in https://github.com/apollographql/apollo-feature-requests.

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

3 participants