1

I have been wondering if a component gets rendered again if the a prop is updated and its not being used in render method. I am using Redux and some unnecessary props have been added to the component with mapStateToProps of connect method. I know I should remove the prop if they are not used, but before I wanted to be sure if it makes any difference.

Craws
  • 576
  • 4
  • 30
Rizvan
  • 521
  • 1
  • 7
  • 20
  • 1
    Is everything clear for you now? If so please mark my answer as accepted if not, let me know! – Craws Nov 22 '18 at 09:10

1 Answers1

2

Yes, on default it will/should rerender.

Take a look at this post: https://stackoverflow.com/a/38678454/9254064

EDIT: https://stackoverflow.com/a/48609609/9254064

Craws
  • 576
  • 4
  • 30
  • 2
    The given link does not clearly points to my question that is why I am not sure even now. but its was helpful. – Rizvan Nov 22 '18 at 09:12
  • 1
    Excuse me, I did not read your question correctly. Please take a look at the second link in my answer. It states that a re-render will only be triggered when the specific props are passed to the specific component. – Craws Nov 22 '18 at 09:18
  • 1
    Did the last link clarify it for you? – Craws Nov 22 '18 at 11:26
  • 1
    By unused prop I mean the prop is not used anywhere in the components render method. I don't see anything clarifying in any link that If a prop is not being used it does not make any difference the component will render again if it changes. – Rizvan Nov 23 '18 at 07:17
  • Let me try to explain it better, the second link states that: "if you would like to re-render your component, you need to" following: "pass updated props to that component from parent" This says that IF you want to rerender a component you have to pass the props to the component. This means that a component on itself will **not** rerender if you do **not** pass the props on your own. – Craws Nov 23 '18 at 08:35
  • 2
    Okay then it means it doesn't matter if it being used or not. get it now. thanks a lot. – Rizvan Nov 23 '18 at 08:51