Skip to content

Predicate function for updating component.  #235

Closed
@coatlicue89

Description

@coatlicue89

It would be nice to have an optional predicate function to pass to the connect function, so we can do the usual further immutable data optimizations.

Something like this:

function connect(mapStateToProps, mapDispatchToProps, mergeProps, updateComponent, options = {})
....
const defaultUpdateComponent = (prevStoreState, storeState) =>  prevStoreState !== storeState;
const finalUpdateComponent = updateComponent || defaultUpdateComponent;

then in handleChange:

handleChange() {
....
  if (!pure || finalUpdateComponent(prevStoreState, storeState)) {
       this.hasStoreStateChanged = true
     this.setState({ storeState })
  }
}

P.D.: Happy New Year!

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