Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upShallowRenderer does not work with Class.contextType #14442
Comments
This comment has been minimized.
This comment has been minimized.
|
Can I take this? |
This comment has been minimized.
This comment has been minimized.
|
Sure. |
This comment has been minimized.
This comment has been minimized.
|
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>
.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@Aberman12 please do! |
This comment has been minimized.
This comment has been minimized.
|
awesome, thanks! |
This comment has been minimized.
This comment has been minimized.
|
Is this being worked on @Aberman12? If not I would love to look into it :) |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
I'm challenging this issue too. I'm trying to get snapshots tests - changing |
This comment has been minimized.
This comment has been minimized.
|
I'm a bit confused with this one now.I went through the React source code and seen a lot of usages of |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
Is this issue taken? I'd love to work on it. |
This comment has been minimized.
This comment has been minimized.
|
Hi, just wanted to check if someone is working on this issue. If not, it'll be my pleasure to work on it! |
Fixes facebook#14442


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.