React Quiz App Tutorial (w/ starter code + working example) | Beginner React Projects

Поделиться
HTML-код
  • Опубликовано: 24 авг 2020
  • In this beginner react project we'll look at how to build a quiz app using React hooks.
    🚨 For more projects check out codecoyotes.com
    🚨 🚨 Starter/Finished Code Repo: github.com/chrisblakely01/qui...
    Run the STARTER CODE:
    1) git clone github.com/chrisblakely01/qui...
    2) cd quiz-app/starter
    3) npm install
    4) npm start
    Run the FINISHED CODE:
    1) git clone github.com/chrisblakely01/qui...
    2) cd quiz-app/final
    3) npm install
    4) npm start
    What we'll learn:
    - Managing complex state objects
    - Conditionally rendering elements
    - Working with multiple state hooks to create a dynamic UI
    🚨 🚨 Get React Project ideas with tips and starter code straight to your inbox: bit.ly/2CoTD6y
    COME SAY HI:
    Blog: www.jschris.com
    Twitter: / chrisblakely01
    Email: hello@jschris.com
    This is a new channel so would love your feedback in the comments.
    Don't forget to like, share, and subscribe! Thanks for watching!

Комментарии • 112

  • @MohamadMohamad-pl4eb
    @MohamadMohamad-pl4eb 2 года назад +4

    you are the only youtuber than i dont have to speed my video to watch you,
    a lot of stuff with only 12 min, keep it up

  • @santra528
    @santra528 Год назад +1

    Thanks Chris for the turtorial. I am new to Angular and I was building quiz app using Angular and I was not sure
    how to go about the logic to calculate the score. Watching this video I was able to implement the logic
    in my quiz app using Angular. Thanks again!

  • @mrgames-Will
    @mrgames-Will 7 месяцев назад

    Great tutorial, Chris! Thank you!

  • @TheMaxZakh
    @TheMaxZakh Год назад

    Fantastic easy to follow explanation!

  • @Screwfacecapone
    @Screwfacecapone 6 месяцев назад

    Nice! I tried it out for myself, and altered it to add additional questions and load them from a JSON doc. Thanks a lot!

  • @sergiob3698
    @sergiob3698 3 года назад

    Good luck with your new channel. Thanks for sharing!

  • @achtube85
    @achtube85 3 года назад +7

    Thanks for this! I learnt a lot! Subbed right away :)
    I have to confess, though, that I found that, for a non-native English speaker like me, not only your accent is a bit challenging (although beautiful!) but also you speak quite fast, so for the first time ever while watching web dev toturials, I set the speed to x0.75 in order to have enough time to process better :)

    • @ChrisBlakely
      @ChrisBlakely  3 года назад +1

      Thank you for subbing! Yes I’m still working on talking slower to suit more people, although talking slow doesn’t come natural to me 😂 thanks again for watching !

  • @raynax3702
    @raynax3702 3 года назад +1

    Your projects are awesome man. Hope you get millions sub soon♥️

    • @ChrisBlakely
      @ChrisBlakely  3 года назад

      Thanks man!! I hope I get to a million as well 😂

  • @lucianolimafer6305
    @lucianolimafer6305 3 года назад +1

    Liked and subscribed. Thanks for this tutorial ..... awesome!!!

  • @codingwitheric
    @codingwitheric 2 года назад

    Great videos man!

  • @lacheporter6675
    @lacheporter6675 3 года назад +10

    Spoilers!!! this is how I made my reset button to reset state (extra credit).
    Just create a function that sets the usestate value back to the orignal value.
    I did name some variables differently. Hope this hint helps for those learning.
    const [currentQuestion, setCurrentQuestion] = useState(0);
    const [showScore, setShowScore] = useState(false);
    const [score, setScore] = useState(0);
    const resetStateClick =()=>{
    setCurrentQuestion (0)
    setShowScore(false)
    setScore(0)
    }
    Put this button inside your score div
    Retry
    For recording the score after hitting retry:
    Add another constant:
    const [recordedScore, setRecordedScore] = useState(0);
    Put this in the resetStateClick from above.
    setRecordedScore(score)
    Add a div.

    Your Last Score: {recordedScore}

    • @chandrikap8168
      @chandrikap8168 10 месяцев назад

      Thank you so much!! You made my life easier!!

  • @dimasaaron3759
    @dimasaaron3759 2 года назад

    Thanks for video, Very useful & GBU Chris.

  • @trungnguyen8252
    @trungnguyen8252 2 года назад

    thank Chris ! it's useful for me

  • @bennyakaz
    @bennyakaz Год назад

    Bro this was great, thank you

  • @crazyiron9003
    @crazyiron9003 2 года назад

    Thankyou OG.Ceb, back to back ti winner.

  • @AminSani
    @AminSani 3 года назад +1

    That was very useful , Thank you so much

  • @musadanjuma6603
    @musadanjuma6603 3 года назад +1

    Liked and Subscribed immediately, thanks for this tutorial, it is exactly what I was looking for...

    • @ChrisBlakely
      @ChrisBlakely  3 года назад +1

      Thanks so much , I’m glad you found this helpful !

    • @musadanjuma6603
      @musadanjuma6603 3 года назад

      @@ChrisBlakely most welcome!!

  • @muhammadhamzashabbir8364
    @muhammadhamzashabbir8364 3 года назад

    Oh My God !! You are legend Bro Thank You so much ,,,,,,,you make my day

  • @dubbsy_
    @dubbsy_ Год назад +1

    Awesome video man... how would you add in Fade-out / fade-in style transitions between questions?

  • @dimalavrenov3916
    @dimalavrenov3916 Год назад

    I am now seriously busy learning react. Initially, I created state, setState, etc. myself, in order to understand how it works under the hood. Now, when I don’t need to write it all by hand, I grasp everything on the fly, so I also understand the theory. Thanks for the lessons. For beginner web developers, this is a very good start. Hello from Russia and thanks again😍

    • @dimalavrenov3916
      @dimalavrenov3916 Год назад

      For starters, cheating on a video is a good topic, but then you need to learn how to do it yourself, looking at the code that you previously copied. For example, I do my own social media. car network. In addition, I do such small projects, and I look at the code of people who have been spinning in this area for more than one year, I also do practice at freecodecamp, whoever has not heard of this, I advise! Well, I watch interviews to see how others answer frequently asked questions.

    • @JayLim-bn9fh
      @JayLim-bn9fh 8 месяцев назад

      hi, from Pakistan. Goodluck on your coding journey.

  • @bhaveshkumarreddy46
    @bhaveshkumarreddy46 3 года назад

    Simply Superb

  • @magdasokolovic
    @magdasokolovic 3 года назад

    nice video, thanks Chris

  • @ThePercivalGlyde
    @ThePercivalGlyde Год назад

    great man thanks

  • @kabir0x23
    @kabir0x23 Год назад

    amazing, thanks..

  • @AzizKhaddaoui
    @AzizKhaddaoui 3 года назад

    wow very nice. thank you for the show

  • @ichbindiego19
    @ichbindiego19 3 года назад

    Muchas gracias excelente, saludos desde México.

  • @anasssanba
    @anasssanba Год назад

    i'm so happy it's my first time doing that quiz app haha it's look the same as yours xD

  • @dmitrybutakov1
    @dmitrybutakov1 2 года назад

    Thank you man! Good luck!Strong like and subscribe

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @hritikchaudhary5470
    @hritikchaudhary5470 2 года назад

    Awesome 👍

  • @hariskhan804
    @hariskhan804 3 года назад

    brilliant

  • @user-rx5yz7hp6t
    @user-rx5yz7hp6t 2 года назад

    Thanks Alot

  • @ferrino4145
    @ferrino4145 3 года назад

    You did some serious magic here Sir, and also saved my...programme :D

  • @shaheensiddiqui1952
    @shaheensiddiqui1952 2 года назад

    sit it was so much useful

  • @frankagu924
    @frankagu924 Год назад

    Beautiful

  • @rangabharath4253
    @rangabharath4253 3 года назад +1

    awesome

  • @tumon001
    @tumon001 2 года назад

    Thanks Bro

  • @elsaiedsamaka7373
    @elsaiedsamaka7373 3 года назад

    nice and easy ,thank you +_+

  • @OleksandrRaduka
    @OleksandrRaduka Год назад

    thanks

  • @ahusyn
    @ahusyn Год назад +1

    I see you have a css class for .correct and .incorrect ready to show if the answer was correct or not, however I wanted to see how that could be implemented? once clicked on answer, where would that go?

  • @noumankhan4381
    @noumankhan4381 Год назад

    thankyou

  • @SatyamGupta-yq1pt
    @SatyamGupta-yq1pt 3 года назад

    Thanks bro

  • @DhiaMagicien
    @DhiaMagicien 3 года назад

    I F**king love this tutotial ❤
    Its so excellent dude !
    Maybe u can reDo it again with a countdown Timer?

    • @ChrisBlakely
      @ChrisBlakely  3 года назад +1

      Haha thanks Dhia!
      Yeah I went a bit too fast in this video so I'm planning to do a second version, maybe using Redux/context API as well.

  • @mohammedshoaib2755
    @mohammedshoaib2755 2 года назад

    Great

  • @replayzor
    @replayzor Год назад

    This is so easy too bad you don't make them anymore they are so helpfull Thanks

  • @yeminhtun2543
    @yeminhtun2543 3 года назад

    great..

  • @Bep33
    @Bep33 2 года назад +1

    Great vid! How would you make the correct option turn green to show the user they got the answer right?

    • @shibanipattnaik5419
      @shibanipattnaik5419 2 года назад +1

      Hi, did you find solution? i am trying to do the same.

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @yuvanhanwat9929
    @yuvanhanwat9929 Год назад

    If we want to show all questions in only one page then what should be the changes in this code. Please help.

  • @NotiCuriosidades
    @NotiCuriosidades 2 года назад +1

    Hi. Great video. A couple of questions. Is it possible to display the questions and answers randomly? 2. Is it possible to see the questions and correct answers at the end? I.e. see all the questions along with the correct answers.

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @windzordave2411
    @windzordave2411 2 года назад +1

    That's awesome man! However, how do I get the value(string) of the user's choice?

    • @ChrisBlakely
      @ChrisBlakely  2 года назад +2

      Thanks for the comment man - I can't exactly remember this but I'm pretty sure there is an onClick function that gets called when the user clicks an answer, you could get it from within that function and store it in state or whatever

    • @windzordave2411
      @windzordave2411 2 года назад +2

      @@ChrisBlakely Yep! I figured it out. Your work is a great help! Thank you

  • @saldanasal1353
    @saldanasal1353 Год назад

    Is possible to save the answers into SQL ?

  • @renatico7733
    @renatico7733 Год назад

    Great video, I want to do a different quiz where each answer gives some points, like answer1 gives 1 point and so on, and the correct answer gives 5 points. At the end of the Quiz it sums up all the points and shows them to the user, any clues to implement this point system here?

    • @veterancode2523
      @veterancode2523 Год назад

      Try this videos it will help you ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @andresramirez4469
    @andresramirez4469 2 года назад +1

    i did my own quiz, (Similar to yours but i used form and split up components, and used radio buttons) but when i was trying to do the score i had so much trouble getting it to increment the score. Until i looked at your video. I dont see how putting in answerOption.isCorrect as an argument at the handleAnswerButtonClick would make it work. Could you explain that or somebody else on here?

    • @osuntuyiemilos5803
      @osuntuyiemilos5803 Год назад

      Hi, I also tried radio buttons but when I click on one option the other options on the next question gets clicked also. How did you navigate this issue? Thanks

  • @Rupali_-pk1jk
    @Rupali_-pk1jk 3 года назад +3

    plz give css of this project

  • @TopTalentBridge
    @TopTalentBridge 3 года назад +2

    Hello chris,
    I am not able to the logic of displaying the previous state please help me with it please share the code

    • @Abogida11
      @Abogida11 3 года назад

      I think you need to save the scores in Local storage and display it

    • @lacheporter6675
      @lacheporter6675 3 года назад

      Check my above comment if your still stuck might help

  • @joyprokash4016
    @joyprokash4016 2 года назад

    damn fast talking style :3

  • @juguetestoys1137
    @juguetestoys1137 2 года назад +1

    Hi, your video is great.
    How can I put an Alert (this answer is incorrect, the correct answer is .... HERE SHOW THE CORRECT ANSWER")

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @DonovanNagel
    @DonovanNagel 3 года назад

    How would you add a 'Click to start again' button to this?

    • @ashprasad9075
      @ashprasad9075 3 года назад +2

      When the code displays the score, set a button which will display the first question and set score to 0

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @abdullahajmal6888
    @abdullahajmal6888 3 года назад

    react native ?

  • @varshas565
    @varshas565 3 года назад

    when answer is correct and incorrect how we display colors

    • @ChrisBlakely
      @ChrisBlakely  3 года назад +1

      use a template string to apply a class to the background depending on the isCorrect boolean (or whatever I named it)

  • @zekisebsib6061
    @zekisebsib6061 2 года назад

    what if i want an image instead of a text message?? can some one help me out

  • @kulsoomsiddiqui7425
    @kulsoomsiddiqui7425 3 года назад

    I score 4 and wanna show that you are lost. how can i do it?

    • @shubhambhavsar23
      @shubhambhavsar23 3 года назад

      Hey, inside of score section add this {score < questions.length ? Try again : You won!}

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @turgutguvercin927
    @turgutguvercin927 Год назад

    There are 8 books in the Harry Potter Series.

  • @thomasters9427
    @thomasters9427 3 года назад

    good tutorial but rather than go at a million miles an hour, why dont you just slow down and make the video longer?

    • @ChrisBlakely
      @ChrisBlakely  3 года назад

      Thanks for the feedback! Yep I’m still trying to find the balance between speed and video length :)

    • @vataidomonkos1783
      @vataidomonkos1783 3 года назад +1

      @@ChrisBlakely I really liked the speed. You can download the files and follow what he is doing. I personally like pausing and rewinding past 10-20 seconds if i don't understand something, more than having to increase the play speed because i'm watching the dude mistype something 4th time or simply because he speaks super slowly and loses his train of thought.
      Thanks for the vid, was super helpful to me.

  • @Emma2491
    @Emma2491 2 года назад

    Please calm down when you speak :)

  • @a_dev7599
    @a_dev7599 2 года назад

    Thanks for the tutorial. I am trying to change border color depending if the answer is correct or wrong with template literals, as suggested but I am doing ir wrong. Please advise how to correct it: {
    handleAnswerOptionClick(answerOption.correct);

    }}>

    • @sherazliaqat2814
      @sherazliaqat2814 Год назад

      try this className={`button ${
      answerOption.isCorrect ? "correct" : "incorrect"
      }`}

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @venkatapenumatsa3959
    @venkatapenumatsa3959 2 года назад

    did anyone figure out, how to add the "Start Again" button at the end of the quiz? I added the below code and seem nothing is happening...! Appreciate any help

    You scored {score} out of {questions.length}
    setCurrentQuestion(0)}
    >
    Reset

    • @veterancode2523
      @veterancode2523 Год назад

      ruclips.net/video/_Vq1Ba26lX4/видео.html

  • @dejansekulic4199
    @dejansekulic4199 3 года назад

    Good luck with your new channel.Thanks for sharing!