Skip to content

bug(populate) - populate returns a new instance of an object on every render, preventing optimization by pure components #342

Open
@fej-snikduj

Description

@fej-snikduj

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

(If this is a usage question, please do not post it here—post it on gitter. If this is not a “feature” or a “bug”, or the phrase “How do I...?” applies, then it's probably a usage question.)

What is the current behavior?
When using populate in the connect function, it returns a new instance of the object everytime the connect function is invoked, regardless of if the data has updated in state or not. This prevents the shallow equals comparison from returning true, and PureComponents cannot optimize for performance.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.
in the connect function, connect to two parts of state, one with populates and one without.
Update the non-populated state data and notice that the one that is populated but wasn't updated returns a new instance every time.

What is the expected behavior?
If the populated data is not live, populate should return a new instance ONLY IF the object containing the child has updated.

If the populated data is live (as coming in a future feature?), then populate should return a new instance ONLY IF the object containing the child has updated OR if the populated data or root has updated.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions