question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connect is not causing render on ownProps change.

See original GitHub issue

My ownProps is an object containing objects. connect looks something like this:

@connect(
  (state,ownProps)=> {
    return {
      stateProp: state.reducer.favouriteReducer.favourites,
      ownProps: ownProps.myProps
    };
  }
)

Props received:

ownProps.myProps { 
   subPropOne: { 
      changedProp: "I was updated why won't you render again? "
   }
}

Also its worth mentioning that a grand parent of this component also has a @Connect on it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
markeriksoncommented, Sep 23, 2016

That example doesn’t really make sense. ownProps is the props passed directly to the connected component by its parent, like <SomeConnectedComponent a={42} b={123} />. You don’t need to include those in the return value from mapState, since connect will combine the incoming props and the mapState results to form the combined props passed to your real component.

0reactions
timdorrcommented, Oct 5, 2016

Looks like some good guidance and answers were given, so I’m closing this out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Re-rendering of connect()ed component based on ...
If props received from parent component are shallowly unequal (have changed) and you use ownProps argument, mapStateToProps is also re-evaluated ...
Read more >
Connect: Extracting Data with mapStateToProps - React Redux
If any of the fields have changed, then your component will be re-rendered so it can receive the updated values as props. Note...
Read more >
Is mapStateToProps causing needless re-renders?
I was recently working on a strange bug at work involving a redux-connected component: a user would hover over a slice of our...
Read more >
Redux: Re-rendering Caused by mapDispatchToProps
I've worked on a couple of React/Redux projects now, and it was only recently that I realized some of the re-rendering issues I've...
Read more >
Mastering mergeProps in Redux - Peanut Butter JavaScript
Components re-render when props change, and in the second example, the component did not have any props change. onClick is still onClick.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found