JavaScript React Basics (retired) Designing Data Flow Adding Players to the Scoreboard

Nhan Tran
Nhan Tran
1,999 Points

What is the difference between function inside propTypes "onAdd" and function outside propTypes onSubmit?

What is the difference between function inside propTypes "onAdd" and function outside propTypes onSubmit?

Steven Parker
Steven Parker
204,846 Points

Could you provide a link to the part of the course where this is introduced?

Arturo Goicochea
Arturo Goicochea
8,077 Points

+1 to this question.

Why was onAdd added inside propTypes, but onSubmit wasn't? What's the difference?

1 Answer

onAdd was added inside AddPlayerForm.propTypes because the onAdd is being passed as a prop from the Application component to AddPlayerForm component. onSubmit is not being passed as a prop from App component, and is defined within class AddPlayerForm. This is why onSubmit was not added inside propTypes. So the difference is that onAdd is being passed as a prop from another component, while onSubmit isn't and is used to submit the AddPlayer form. Does this answer your question?