Question:
Within my component I have a ‘OnClick’ handler that is supposed to fire a function called ‘onSelectProject’ within mapDispatchToProps that dispatches actions to the store. In this case it passes the id of the project passed from the click eventThe problem I am having is that onSelectProject is firing for every project on a single click. If I have 10 projects the console.log within the function will show 10 times, one for every project.
index.js (ProjectComponent)
I can provide more code if necessary or requested.
Answer:
make sure to pass function references not actual calls so your function is not called on every render but when you actually click the button:If you have better answer, please add a comment about this, thank you!