jonasschmedtmann/ultimate-react-course

Chapter 10 video 119 Improving reusability with props

LieutenantCobretti1998 opened this issue · 0 comments

The StarRating component currently expects a function to be passed to the onSetRating prop. If this prop is not provided, the application throws an error when trying to execute onSetRating as it is undefined. The StarRating component should have a default behavior defined for onSetRating to avoid TypeError when the function is not provided. This will enhance the component's robustness and prevent potential runtime errors. I found this error for the movie list app in Star component. . Please check it and add this verificator for avoiding questions about it 😁

function handleRating(rating) { setRating(rating); if(onSetRating) onSetRating(rating); }