Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
functionQuizLogic(showScore,totalTime,fetchQuestions,loading,currentQuestion,questions,handleAnswerOptionClick,countDownBarWith){constrouter=useRouter();console.log('loading',loading);// You'll see what's the content of loading
I would say (without having take a look at the rest of the code) that loading is something set in runtime in a different place (maybe a state) so instead adding the if before, you can do
Add a console log like that:
I would say (without having take a look at the rest of the code) that loading is something set in runtime in a different place (maybe a state) so instead adding the if before, you can do
This way it will check that
loading
is not undefined neither null before checkingloading.current
.You may also add default values for props:
I've added it just in loading but I recommend to do that on each of them. You can either use this approach, or using prop-types or both combined.
Last but not least, you may want to split your logic into different functions to keep it SOLID and KISS. 😁