<button
className="delete-btn"
onClick={(event) => props.deleteNote(event, note.id)}
>
The code above is for a button that when clicked, calls a function that is in another component and should pass note.id as its parameter.
To my understanding, when we need to pass a function with extra parameters as props, we need to pass the whole callback function as written above.
However, I tried this version of code that doesn't include the event as the parameter for the callback function, and it seems to still work. Is there an important difference between the code snippets?
<button
className="delete-btn"
onClick={() => props.deleteNote(event, note.id)}
>
It depends on whether you need to do something with the event (like getting data from it or preventing the default action) or not. This is my opinion but i like to always pass it for good measure.