Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

HOC violates contract of componentWillReceiveProps #1611

@rocketraman

Description

@rocketraman

Intended outcome: When I wrap a component with a graphql HOC, the behavior of React's calls to componentWillReceiveProps on the underlying component should not change.

Actual outcome: Currently, when wrapping with a HOC, componentWillReceiveProps is no longer called in situations in which it should be.

This is due to the shallowEquals done on all props here:

shallowEqual(this.props, nextProps) &&

This comparison should either be removed, or it should account for props not managed by the HOC.

How to reproduce the issue:

  1. https://codesandbox.io/s/4q0645k8w
  2. Click on render.
  3. Click on Set state foo=false.
  4. Click on render again.

In step 4, the component state should update via componentWillReceiveProps. It does not.

In this sandbox, we have the exact same App component, without the Apollo HOC: https://codesandbox.io/s/xpyjmknp14 and you can see that the behavior is now correct.

Version: 2.0.4

  • apollo-client@2.2.1
  • react-apollo@2.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions