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
ShallowRenderer does not work with Class.contextType #14442
Comments
Can I take this? |
Sure. |
Yes
Den søn. 3. feb. 2019, 18:57 skrev Alex Berman <notifications@github.com:
… Is this issue still being worked on @charBap <https://github.com/charBap>?
If not id be glad to take it on! @gaearon <https://github.com/gaearon>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#14442 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/As-519wKdzNgTDFhGpxUMPXeVllO_IwQks5vJyMegaJpZM4ZT9xF>
.
|
@Aberman12 please do! |
awesome, thanks! |
Is this being worked on @Aberman12? If not I would love to look into it :) |
Hi, I want to start collaborating with open source often and, as I had worked with React for some time, I thought it would be nice to start collaborating here. I've been looking into this issue and I suppose it's a user mistake and not a bug. First, there is a typo in Second, I dig into the ReactContext to understand it more, and I suppose that it isn't used for creating element contexts, but has some use in server-side rendering and concurrency with threads. So, trying to use Saying this, IMO, this is not a bug and can be closed. |
It's not a typo, It's more like leftover from Legacy Context API where It was in plural. If I am not mistaken, changing @gaearon I'd like then take this one, If It's possible. |
I'm challenging this issue too. I'm trying to get snapshots tests - changing |
I'm a bit confused with this one now.I went through the React source code and seen a lot of usages of |
Seems like
while newer (unsable) code is using class component propretry 'contextType' and some existing code suggests that both should be used while newer convention should take precedence over the older one. here @gaearon should the fix be considering both old and new component propreties OR omit the old plural |
Is this issue taken? I'd love to work on it. |
Hi, just wanted to check if someone is working on this issue. If not, it'll be my pleasure to work on it! |
The shallow renderer has moved to https://github.com/NMinhNguyen/react-shallow-renderer. If this is still relevant, please feel free to file this issue there. Thanks! |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
The shallow renderer from the 'react-test-renderer' package does not work with Class.contextType. The component always receives an empty object as the context.
What is the expected behavior?
The shallow renderer should forward the context provided to the render method to the rendered component's this.context.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.6.3
Steps to reproduce
The test below can be used to reproduce the problem (Open on codesandbox.io). The first test reproduces the bug and the second test shows a workaround.
The problem seems to be located here. The function getMaskedContext() checks the properties declared on type.contextTypes and filters out the properties from the context provided to the shallow render unless the types.contextTypes is declared.
The text was updated successfully, but these errors were encountered: