React: Context.Consumer unexpectedly updates each time one of its child components call setState

Created on 12 Feb 2018  路  2Comments  路  Source: facebook/react

Do you want to request a feature or report a bug?

  • Report a bug

What is the current behavior?

  • Each time a child component of Context.Consumer calls setState, its parent Context.Consumer re-renders.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

What is the expected behavior?

  • Presumably the expected behavior is one where setting the state of a child component does not affect any parent Context.Consumer components, particularly when that state does not change

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

  • Versions

    • 16.3.0-alpha.1

    • 16.3.0-alpha.0

  • Browser

    • Chrome (OSX 10.13.3) 64.0.3282.140

  • This works as expected when the previous context API is used
Bug

Most helpful comment

Woo hoo! Thanks for the incredibly detailed bug report! I know why this is happening and it's an easy fix. We'll get this working before the release.

All 2 comments

Woo hoo! Thanks for the incredibly detailed bug report! I know why this is happening and it's an easy fix. We'll get this working before the release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jvorcak picture jvorcak  路  3Comments

zpao picture zpao  路  3Comments

krave1986 picture krave1986  路  3Comments

trusktr picture trusktr  路  3Comments

zpao picture zpao  路  3Comments