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

Fix new Context handling (react@^16.6.x) #45

Closed
SleepWalker opened this issue Nov 21, 2018 · 0 comments
Closed

Fix new Context handling (react@^16.6.x) #45

SleepWalker opened this issue Nov 21, 2018 · 0 comments

Comments

@SleepWalker
Copy link
Contributor

SleepWalker commented Nov 21, 2018

As of react 16.6 the both Provider and Consumer types has _context property, which leads to context loss whenever we are visiting Consumer:

if (currentElement.type._context) {
  // eslint-disable-next-line no-param-reassign
  currentElement.type._context._currentValue =
    currentElement.props.value
}

The most naive way to fix it is to check whether we actually have value prop. There is more advanced approach here: jaydenseric/graphql-react@v3.0.0...v4.0.1#diff-3e6d5558503509cddfcf7ef1bc7ee575

Here is a demo of an error: https://codesandbox.io/s/o4wrj5m0jy

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

1 participant