Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Child context for shallow rendering API #567

Closed
DullReferenceException opened this issue Aug 30, 2016 · 4 comments
Closed

Child context for shallow rendering API #567

DullReferenceException opened this issue Aug 30, 2016 · 4 comments

Comments

@DullReferenceException
Copy link

When testing our HOC-wrapped components, we often use the pattern of shallow-rendering one more level deep:

class MainComponent { /*...*/ };
export default connect(/*...*/)(MainComponent);
const tree = shallow(<WrappedComponent/>, { context }).shallow();

The problem is that the child context is not being propagated, so when the inner component is rendered, its context is missing.

I see that a childContextTypes option was provided when doing a full render here: #171, but shouldn't we have the same thing for shallow rendering?

@AshCoolman
Copy link

From the same discussion:

there is no need for it in ShallowWrapper.. (the problem was with context of deeper child nodes, there are none in ShallowWrapper)

@DullReferenceException
Copy link
Author

DullReferenceException commented Sep 6, 2016

Yep, that was the comment, but there is the need for establishing child context if you're rendering child nodes (through calling .shallow() for example) even with shallow rendering.

@ljharb
Copy link
Member

ljharb commented Jul 6, 2018

Highly related to #664.

@ljharb
Copy link
Member

ljharb commented Feb 26, 2019

Fixed in #664.

@ljharb ljharb closed this as completed Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants