How to Make a Star Rating Component in React

Поделиться
HTML-код
  • Опубликовано: 13 июн 2024
  • Here's how I create a star rating component in React. You'll use this in an application where you'd like to give users the ability to rate something on a scale from 1-5, or whatever scale you'd like.
    Twitter: / ericnmurphy
    Website: ericmurphy.xyz/
  • НаукаНаука

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

  • @korneliafrey9780
    @korneliafrey9780 3 года назад +8

    Thanks a lot man! What a bliss to watch a video with clear, easy to follow instructions, non of that overcomplicated stuff. Really appreciate this content. Thanks again!

  • @JustSkillGG
    @JustSkillGG 4 года назад +12

    Dude thanks a lot!
    Your speech is very clear and your explanation is really good!
    This channel will definitely explode if you continue the videos!

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

    this kind of video feels so much more organic than typical coding tutorials,
    Thank you~

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

      Thanks! I enjoy watching these kinds of tutorials more than the more polished tutorials as well.

  • @be-kreidly1515
    @be-kreidly1515 3 года назад

    Thanks Eric! you have a good teaching talent, i hope you have most of the react widgets in ur channel

  • @anuragv2319
    @anuragv2319 4 года назад

    Best Video I have seen. Keep making such videos. It's really helpful.

  • @vegito1877
    @vegito1877 2 месяца назад

    Thanks bro it was really helpful!!
    I watched a lot of videos out there but this was really easy to understand.

  • @iulia516
    @iulia516 4 года назад +2

    Thanks a lot for this!
    I'm hoping to see similar content in the future. You're doing an awesome job! :)
    Cheers!

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

    great video - thank you! I was having a 'Warning: Each child in a list should have a unique "key" prop." I added key={i} to the label tag and that solved that issue. I share this in case someone else encounters that problem.

  • @HugoSanchez-kd7qz
    @HugoSanchez-kd7qz 3 года назад +3

    This made my work so much easier! Thank you for this!

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

      Hello, Hugo Sanchez.Where are you from?

  • @davidjentjens2711
    @davidjentjens2711 4 года назад +1

    Fantastic video man. Keep it up!

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

    Great tutorial. Simple and works. Thanks!

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

    THE BEST tutorial. Thank you! Just subscribed

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

    You are the biggest life saver of them all earned a sub an a new viewer for sure keep it up

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

    amazing and I loved the way u explained everything! big thank u!

  • @emerlenderz
    @emerlenderz 4 года назад

    Nice video mate, very clean and understandable code!

  • @RabeeRaad
    @RabeeRaad 4 года назад +1

    Neat and direct to the point, Thanks for sharing.

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

    This is so great. Thanks for teaching!

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

    Thank you, bro, that was usefully and very clear explanation, thanks.

  • @amroeloks8745
    @amroeloks8745 4 года назад +1

    thanks bro, simple and beautiful!!

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

    Thank you sir! short and precise

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

    Bruh this was awesome. Worked like a charm. :)

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

    Thanks man ! Nice video, very helpful

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

    Big Help. Easy to follow and understand

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

    Thank man ! every thing is so much clear.

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

    thank you man your explanation is good so i've subscribed please upload more of react videos.. thank you

  • @samrathsinghsaini3706
    @samrathsinghsaini3706 9 месяцев назад

    Super helpful! Keep going bro ⚛⚛

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

    So perfect ..Thanks a lot for this one~!

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

    Thank you man, This help me a lot

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

    This video is so great. If you came to Vancouver, I must buy you a drink!

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

    Thanks a lot man!!!! I loved this video... that is crazy!!

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

    Thank you so much for this video!

  • @h.m.zakariasumon1644
    @h.m.zakariasumon1644 4 года назад

    thank you boss ... really your explanation is good

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

    Amazing video!

  • @Vladeasa
    @Vladeasa 4 года назад +1

    Nice work. I like your clean style

    • @Vladeasa
      @Vladeasa 4 года назад

      Do you have a suggestion on how to create a rating ratio?

    • @EricMurphyxyz
      @EricMurphyxyz  4 года назад

      @@Vladeasa Thanks! What do you mean by rating ratio?

    • @Vladeasa
      @Vladeasa 4 года назад +1

      @@EricMurphyxyz wow. this was a quick reply, thanks. so if multiple users rate, it will create the average star rating based on their rating

    • @EricMurphyxyz
      @EricMurphyxyz  4 года назад +1

      @@Vladeasa Good idea, will probably cover that in a future video!

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

    Excelente!! Justo lo que necesitaba!! Gracias!!

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

    BROOOOOOOOOOOOO YOU ARE THE MAN!!!!!!!!!!!!!!!!!!!!! thank you so much

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

    Very good job.
    Thank you.

  • @sugandharramakrishnan7957
    @sugandharramakrishnan7957 4 года назад

    Thanks for the great content ,your doing a great job keep going ....👍🏻
    how would you make it as half star rating..?

  • @JawadAhmed-lh6jr
    @JawadAhmed-lh6jr 2 года назад

    Thanks a lot Bro! You should have more 1m subscribers

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

    Very nice tutorial :)

  • @freefirezone2902
    @freefirezone2902 3 месяца назад

    Thanku bro thanku so much ❤ respect from my heart

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

    Thanks, really helped a lot👍

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

    Great tutorial! Do you have a React Native version for this?

  • @soussivic7437
    @soussivic7437 4 года назад

    Dude thanks a lot!
    But how can i store the rating? like when i refresh the page i don't want the rating to be gone cause i wanna render that rating in other components of my posts ?

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

    THANK YOU! You saved my day

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

    Great Video. Thank you so much :)

  • @CarvinicioX
    @CarvinicioX 11 месяцев назад

    Many thanks for this!!!!!

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

    Hey dude, thanks for the video. Got a reason to learn making react components. Btw which terminal are you using
    ?

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

      Thanks! The terminal is alacrity, I might make a video on it later.

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

    Thanks a lot!

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

    hey! loved the video, very clean and stream-lined explanation. i'd love to see how to go about storing the star rating for each route in somewhat of a database. say i have blog posts and wanted to enable each post to be rated. where and how do I store the ratings? i've seen some stuff with Firebase but i'm quite the newbie here, a bit clueless :)

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

      Will make some videos on Firebase and databases soon!

  • @anastasiamajewski6490
    @anastasiamajewski6490 4 года назад +2

    Hi Eric! nice video, it helped me a lot. How would you store the rating value that was set in local storage?

    • @EricMurphyxyz
      @EricMurphyxyz  4 года назад +1

      Glad it helped! The same time you set the state in the onChange event, you would save to localStorage with something like localStorage.setItem('starRating', JSON.stringify(value)). Then whenever the page loads (e.g. in a useEffect hook), you would do the opposite with getItem and set the value to state. developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

    • @anastasiamajewski6490
      @anastasiamajewski6490 4 года назад

      @@EricMurphyxyz thank you Eric 😊👍

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

      Hi Anastasia, did you manage it? If so, can you please share your answer?

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

    Thank you so much!

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

    thanks!, I will use this treasure of code :)

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

    Great job!

  • @enayatullarezaie
    @enayatullarezaie 7 месяцев назад

    what is the font that you set it to your vs code editor. i like it a lot

  • @thanhsang6157
    @thanhsang6157 4 года назад

    thank you so much !

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

    Hello! I'm trying to do this but I want just one star to remain selected and I don't really succeed. Do you have any hints ? they will help me a lot. Thanks ! 🙂

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

    thanks for this video

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

    Do i need to restart chrome after installing the extension? For some reason it is saying my REACT APP isn't a react page.

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

    Thank you super clear

  • @keithbrien5317
    @keithbrien5317 4 года назад

    how would you increase by half a star instead of a full star? Very good video

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

    how can we do this rating globally in different route? currently its work for locally, when i try to do it globally its select all the item in the array

  • @nataliasmalii393
    @nataliasmalii393 4 года назад

    Great! Thank you!!!

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

    Thanks bro. How can I display the average of rating which by people rated on our website????

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

    Thank you!

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

    Hi thanks a lot alrdy :) Is it possible to make half stars? Like 4,5

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

    many thanks bro

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

    Thank you :D

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

    thank you

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

    Thanks a lot for this. Are you sure that the order of the elements in the (hover || rating) make a difference ? Shouldn't it be true anyway if any of these is true ?

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

      Right, my mistake. Those can be in any order.

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

      @@EricMurphyxyz Actually you are right. Still need to figure out why this is but I was definitely wrong.

  • @kevin6050
    @kevin6050 4 года назад

    Would there be anyway to make it half stars?

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

    Thank you

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

    thanks man

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

    ive tried this method and it works pretty good other than i cannot figure out how to hide the radio button. even tho you show how you do it, it doesnt work for me

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

    Hey hi Eric ur video was really helpful just a small query what if the ratings are numbers that is coming from any data set how can I convert those numbers like 4,5,3 or any number into star rating for example in my data set ratings set by customer is 4 now i just want to take that data and pass it on to my star component to show those exact ratings as star ratings how am i supposed to pass that number into this component so that directly it displays me rating according to that instead of asking me for input can you please help !

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

      I would do the same as this video, but instead of coloring them in based on the selection, color them in based on the value from your customer that you pass in. May do a video on this later!

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

    thx! You are best
    :*

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

    How would you reset the rating value when you use it in a form after submission?

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

      Set the rating state to null? It depends how you have it set up

  • @Android-um8pe
    @Android-um8pe 4 года назад +2

    Hello, Excellent video. Liked and Subscribed. Can u explain on how to store those ratings done by a user in the MongoDB ? This will be really helpful for me. Thanks in advance :)

    • @EricMurphyxyz
      @EricMurphyxyz  4 года назад

      I like MongoDB, may do some videos about it in the future!

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

    Thanks a lot man, but the problem is, why I couldn't figured it out by myself? can you give us an advise to make our logic works better? thank you

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

    One cuestion: Why don't work the hover in responsive way? whe I take responsive way in a developer tool, the hover isn't run. Thanks! the video it's really good

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

    Okay then how do I get this ratingValue in another component?

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

    thanks alot , by the way whats your theme ? :)

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

      It's Monokai Pro Spectrum, you can search for it in the extension store

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

    nice explain

  • @HoangNguyen-zv3xb
    @HoangNguyen-zv3xb 2 года назад

    Hi Eric how do you display stars based on a given number from an api call like 3/5 ?

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

      Pass the number from the api call down via props and pass it to the star rating component

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

    this video was very helpful than you very much

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

    thanks man :)

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

    How to add half star functionality?

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

    lovely .

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

    what operating system are you using in this video?

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

    that is smart!

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

    How to set the star rating value to null after a button click?Please help me out

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

    What is your color theme in Vsc

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

    спасибо

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

    How can I get the rating value to a parent form that called this component?

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

      You would declare the state in the parent component and then pass down setValue to the child via props. You can then access the value in the parent.

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

      @@EricMurphyxyz Wow, that as fast, thanks!

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

    10 / 10

  • @i.sapnadip
    @i.sapnadip 2 года назад

    thanksssssssss

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

    when i refresh the page will it be lost? How to serve customers?

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

      Save it to a database

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

      @@EricMurphyxyz for each address I store them in an existing object and have key: value as starRating: number. How can I use number in starRating to display the number of stars of each address in an array with many objects in it, thank you and sorry for my bad english

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

      @@quangaonguyen7898 Loop over the array with something like map and pass the starRating value to the StarRating component

  • @willydavid_
    @willydavid_ 4 года назад

    Hello friend, I saw the video and you did not use any module or external npm library but it confuses me that at the beginning you put "react-star-rating" that is the name of a library or the name of the project that you create with create react app, because there are a library called so i thought you use it cameronroe.github.io/react-star-rating/

    • @EricMurphyxyz
      @EricMurphyxyz  4 года назад +1

      Yeah, react-star-rating is just the name of the example project I made, nothing to do with the npm library. You can do it easily yourself, no need to bring in a library to do the star rating component for you!

    • @willydavid_
      @willydavid_ 4 года назад +1

      @@EricMurphyxyz Thank you

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

    Vscode theme?

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

    Did any body gets this ?--Parsing error: Unexpected character '≤'.

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

      Sounds like you need to find and remove the invalid character