Full React Tutorial #27 - Controlled Inputs (forms)

Hey gang, in this React tutorial we'll see how to use input fields & track what a user types into them, using controlled inputs.
🐱‍💻 🐱‍💻 Course Files:
+ github.com/iamshaunjp/Complet...
🐱‍👤🐱‍👤 JOIN THE GANG -
/ @netninja
🐱‍💻 🐱‍💻 My Udemy Courses:
+ Modern JavaScript - www.thenetninja.co.uk/udemy/m...
+ Vue JS & Firebase - www.thenetninja.co.uk/udemy/v...
+ D3.js & Firebase - www.thenetninja.co.uk/udemy/d...
🐱‍💻 🐱‍💻 Helpful Links:
+ HTML & CSS Course - • HTML & CSS Crash Cours...
+ Modern JavaScript course - • Modern JavaScript Tuto...
+ Get VS Code - code.visualstudio.com/
🐱‍💻 🐱‍💻 Social Links:
Facebook - / thenetninjauk
Twitter - / thenetninjauk
Instagram - / thenetninja

Пікірлер: 180

  • @dynerushd7517
    @dynerushd75173 жыл бұрын

    The fact that this react course is completely free is insane, Your way of teaching is really clear and easy to understand. Keep it up my man you are god given.

  • @natnaelghirma2617

    @natnaelghirma2617

    3 жыл бұрын

    God*

  • @spennybad
    @spennybad3 жыл бұрын

    /* create new blog form */ .create { max-width: 400px; margin: 0 auto; text-align: center; } .create label { text-align: left; display: block; } .create h2 { font-size: 20px; color: #f1356d; margin-bottom: 30px; } .create input, .create textarea, .create select { width: 100%; padding: 6px 10px; margin: 10px 0; border: 1px solid #ddd; box-sizing: border-box; display: block; } .create button { background: #f1356d; color: #fff; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; }

  • @GMBgTTg4d

    @GMBgTTg4d

    3 жыл бұрын

    thx

  • @astrix8812

    @astrix8812

    3 жыл бұрын

    thanks king

  • @Ramification

    @Ramification

    3 жыл бұрын

    Thank you good sir!

  • @stanislausalvajufinto8735

    @stanislausalvajufinto8735

    3 жыл бұрын

    You dropped this 👑, king

  • @SM-vo5gj

    @SM-vo5gj

    2 жыл бұрын

    thank you

  • @emmanuelamodu2390
    @emmanuelamodu23903 жыл бұрын

    Thank you so much, having such quality content for free is mindblowing

  • @pulledporksammiches
    @pulledporksammiches Жыл бұрын

    I would hit the like button every time i watch this if I could. Great way of explaining React my dude. It's been hard for me to understand React, but in the last several months, I've been determined to get really good. I've watched this video like 5 times already easily. And every time I do, I can confirm that it has sunk in way more every time.

  • @NetNinja

    @NetNinja

    Жыл бұрын

    That's fantastic to hear Susan, sometimes it takes a while to cement in, but once it does, hopefully it sticks :) I find that application and giving yourself little challenges help aid this even more so! (learn by doing).

  • @gradientO
    @gradientO3 жыл бұрын

    Off-topic, but can you show your desk setup?

  • @maskman4821
    @maskman48213 жыл бұрын

    recap this episode talks about two-way data binding ( a very important concept in reactjs, usually used in form element ) 1. assign a dynamic value to 'value' attribute of input/textarea/select element. example const [name, setName] = useState('mario') 2. listen 'change' event with a handler (anonomous function) to set value, for example setValue(e.target.name)}> thats it !!!

  • @yashrdoshi

    @yashrdoshi

    3 жыл бұрын

    I'm reading your recap in every video. That's really useful !!

  • @jackw.3978

    @jackw.3978

    2 жыл бұрын

    @@yashrdoshi I still don't understand why exactly the value of the input needs to be set to the the dynamic value. And why it is letting him change the text in the input after he implements the onChange event. Would like to understand what happens in the background...

  • @carmensandoval5581

    @carmensandoval5581

    2 жыл бұрын

    @@jackw.3978 Great question Jack! The onChange attribute fires everytime the value of the input is changed. And since the onChange event is grabbing a reference of the value attribute's value to set a state variable, we must set the value attribute to a 'dynamic value'. I hope this helps.

  • @nielfollero5

    @nielfollero5

    2 жыл бұрын

    What I don't understand is why do we need to assign the value of an input since we don't use this in anything. When we need the value of that input, we use the state to process it(maybe pass it in the backend or something), not get the actual value reference from the actual element.

  • @tarekghosn3648
    @tarekghosn3648 Жыл бұрын

    even though i watched your videos before and coded with you. this coming back to them shows me more detail. thank you

  • @wanyingli246
    @wanyingli2463 жыл бұрын

    I watched this series yesterday and I catch up with it today! Shaun is definitely a life saver! I bought some React course in Udemy and I just can't stand the instructor's speaking tone, and I am easily distracted by hearing this, but I love shaun's teaching style!

  • @juggysingh1470

    @juggysingh1470

    3 жыл бұрын

    I have done the same, following courses from Udemy, but never fully grasping REACT as I also had issues with the tutors way of explaining too, until that is I found Net Ninja, he is a Legend!!!!

  • @kashmirtechtv2948

    @kashmirtechtv2948

    2 жыл бұрын

    But where to go from here after finishing this series?

  • @01dicktracy
    @01dicktracy Жыл бұрын

    I did not know I can understand everything so easy. Thank you so much Shaun!

  • @juggysingh1470
    @juggysingh14703 жыл бұрын

    If you want to use default text in your input, then have it clear on click, here is an example of how to do it; // input state const [title, setTitle] = useState('Default Text'); // add initial title state value here setTitle(e.target.value)} onClick={(e) => setTitle('')} // clear input on click /> Also, thanks for your great work Net Ninja, I have subbed now, as that's the least I can do for your great tutorials.

  • @shahiqqureshi7652

    @shahiqqureshi7652

    5 ай бұрын

    Good suggestion, personally I think it might be better to use the placeholder attribute, because if someone goes back to edit that field it will reset.

  • @LGgos
    @LGgos2 жыл бұрын

    thank you it helped me quickly understand how it works after I had an implementation question in an interview that didn't go so well

  • @shingiraibondai747
    @shingiraibondai7472 жыл бұрын

    Short and precise , I LOVE IT. 😍😍😍😍

  • @peterluo1776
    @peterluo1776 Жыл бұрын

    This got to be the simplest explanation I've encountered. Awesome video.. Thanks for sharing 👍

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Thanks for watching Peter :)

  • @hayoudoing
    @hayoudoing11 ай бұрын

    Straight to the point. Thanks a lot!

  • @michaelandersen8570
    @michaelandersen85703 жыл бұрын

    Honestly you just might get me at job next week. I've got a test coming up this Thursday and this series is just *chef's kiss*. Thank you SO much. I'll be sure to send some money in your direction if it goes well. There is so much content on KZread but none that fits my current level better than yours. It is wonderful to know that your content is up-to-date, uses best practices, and is of great production value. The Github repo is also super nice to have. 💪

  • @TheRahulDBZ

    @TheRahulDBZ

    3 жыл бұрын

    Good luck

  • @michaelandersen8570

    @michaelandersen8570

    3 жыл бұрын

    Got the job! Gonna sign up for the Udemy course.😎

  • @michaelandersen8570

    @michaelandersen8570

    3 жыл бұрын

    @@TheRahulDBZ Thank you. Pretty stoked about it. 🚀

  • @mistersir3185

    @mistersir3185

    3 жыл бұрын

    @@michaelandersen8570 any important tips you can give to someone like me who's looking to apply for jobs?

  • @michaelandersen8570

    @michaelandersen8570

    3 жыл бұрын

    @@mistersir3185 I can only speak for myself, and to be honest a lot of it has to do with pure luck. Best tip I can give is to code as much as you can and put it on Github. Make your own stuff and take inspiration from tutorials in the beginning - but avoid pure copying. When you have built a few small projects you'll have confidence in yourself and it will reflect in the way you write about yourself in your resume. I think recruiters pick up on this. And it will also help tremendously at an interview.

  • @TripeDemo
    @TripeDemo Жыл бұрын

    Extremely useful and simple explanation, thank you!

  • @ohitsmekirst
    @ohitsmekirst3 жыл бұрын

    Not one to comment usually but this might just be the best explanation I've seen. Top quality content!

  • @digvijayyamagekar4300
    @digvijayyamagekar4300 Жыл бұрын

    this is some quality stuff bro, thanks for putting it on youtube for free 🤩

  • @wenlongzhang5262
    @wenlongzhang5262 Жыл бұрын

    Great tutorial of controlled inputs! I cannot thank you more!

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Thanks Wenlong!

  • @alexmwansa6414
    @alexmwansa64142 жыл бұрын

    You have no idea how much I love your videos and how much they have helped me. Thank you for your service.

  • @melssf7852
    @melssf7852 Жыл бұрын

    have I told you lately that I love you? :D You just took something that was confusing me and simplified it so well. Your free content led me to buy one of your udemy courses and I plan to buy a few more because you explain things in a way that just clicks for me. Thank you Shaun, truly...

  • @NetNinja

    @NetNinja

    Жыл бұрын

    That is awesome to hear Mels :) your support is much appreciated!

  • @adriennegrace2465
    @adriennegrace24653 жыл бұрын

    Thank you - loving this series so far! One comment - for accessibility, you should keep the htmlFor attribute in the label and use the input id attribute, so they are connected.

  • @TimWinfred

    @TimWinfred

    2 жыл бұрын

    Yes! Literally was just about to say this!!!

  • @heroinedecheshire7065
    @heroinedecheshire70657 ай бұрын

    You're amazing! I always thought forms are a pain in React but you cleared them up for me! These videos are amazing and this is what passion looks like!

  • @NetNinja

    @NetNinja

    7 ай бұрын

    That's brilliant to know :) glad it helped!

  • @terrencejanairo2675

    @terrencejanairo2675

    7 ай бұрын

    @@NetNinja do you have router v6 in this project?

  • @giroda
    @giroda2 жыл бұрын

    splendid narration, neat and clear, top!

  • @WEBDEVIndo
    @WEBDEVIndo3 жыл бұрын

    awesome mentor. I am sure he is really expert in this field .

  • @simonkalu
    @simonkalu3 жыл бұрын

    I'm proud of net ninja

  • @CodeRCreatives

    @CodeRCreatives

    3 жыл бұрын

    yaa me too...he is amazing at his work

  • @jAMES-xy6wh
    @jAMES-xy6wh2 жыл бұрын

    I came here to learn about React Router, and I found a goldmine of information. What a fabulous course!! And it is Free? How do I compensate you for your labor?

  • @rogeclash2631
    @rogeclash2631 Жыл бұрын

    As always many thanks for teaching all these

  • @melindamurillo4680
    @melindamurillo46802 жыл бұрын

    Extremely helpful. Thank you very much

  • @learningit2572
    @learningit2572 Жыл бұрын

    Net Ninja, You are a Legend!!!! Best of the Best

  • @averageromanian3940
    @averageromanian3940 Жыл бұрын

    A complex topic made simple. Very nice video!

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Thanks!

  • @0x0abb
    @0x0abb2 жыл бұрын

    awesome work - once again

  • @jagaroTV
    @jagaroTV6 ай бұрын

    This is much better than a paid tutorial..EXCELLENT JOB NET NINJA

  • @umuthankuzur3184
    @umuthankuzur31843 жыл бұрын

    Hi ninja. Thx for all the playlist again. But i have a question in particular this session. U wrote repetitive code in this file to handle state but u could eliminate code via using a form state object. Why didnt u that? Is because of u dont want trigger updating whole object on all types? Is this for upgrading performance?

  • @chhumchanleak7642
    @chhumchanleak76422 жыл бұрын

    Thank you mr for saving me from headache

  • @ruin9
    @ruin95 ай бұрын

    I really love this accent ,keeps the video interesting

  • @NetNinja

    @NetNinja

    5 ай бұрын

    Thank you! 😃 I made it myself

  • @mohammedsaheed9847
    @mohammedsaheed98473 жыл бұрын

    It's really awesome having this tutorial for free. Thank you very much. However, I'd like to know if it's possible to use json server for authentication, or if you have any tutorial on user form validation and authentication with json. Thank you

  • @jakubbarabasz3560
    @jakubbarabasz35602 жыл бұрын

    Realy helpful series!!!

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thanks Jakub

  • @pauloferreira4040
    @pauloferreira40402 жыл бұрын

    Maybe a dumb question, but why do you need the code on line 14 (value = {title})? The person typing inside the text field is already changing its value right? Correct me if I am wrong, but I believe that this code would be useful in situations when the {title} is changed (using the setTitle, of course) by some external event (not necessary for this specific blog page example of yours), e.g., a case where we could allow the user to come back to an unfinished blog entry and the title input field would then be populated with the contents of an earlier-entered {title} variable. Is that the right way of seeing this? thanks

  • @GiancarloCarccamo
    @GiancarloCarccamo2 жыл бұрын

    great video man

  • @Gamerfan2000
    @Gamerfan20003 жыл бұрын

    Hello Shaun, Can you please tell me, what extension you used for the javascript syntax theme? For example yellow for the variable/method declarations and purple for the return method, etc? Thank you in advance, PS. Your tutorials are the best on the internet. Cheers :)

  • @arrozfritoo
    @arrozfritoo3 жыл бұрын

    3:07 thats was the best uh uh i heard in my life

  • @njabulothwala5152
    @njabulothwala51522 жыл бұрын

    This is so Good man 😁😁😁

  • @adamksiazkiewicz3643
    @adamksiazkiewicz36432 жыл бұрын

    Very good stuff. Save my day.

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Glad to hear it! Thanks for watching Adam :)

  • @Human_Evolution-
    @Human_Evolution-3 жыл бұрын

    The best vieo on this subject. I spent 45 min looking until I found you. All others are inferior.

  • @ahmedpatel408
    @ahmedpatel408 Жыл бұрын

    TY Mate

  • @nylivehc9008
    @nylivehc9008 Жыл бұрын

    I don't know why I laugh with the yohoo! 😂

  • @emmuoriginals5296
    @emmuoriginals52963 жыл бұрын

    Thanks ninja

  • @elyeskabous2343
    @elyeskabous23438 ай бұрын

    Thank you so much

  • @NetNinja

    @NetNinja

    8 ай бұрын

    No problem :) hope it was helpful

  • @tarokins
    @tarokins3 жыл бұрын

    Form Styles: /* create new blog form */ .create { max-width: 400px; margin: 0 auto; text-align: center; } .create label { text-align: left; display: block; } .create h2 { font-size: 20px; color: #f1356d; margin-bottom: 30px; } .create input, .create textarea, .create select { width: 100%; padding: 6px 10px; margin: 10px 0; border: 1px solid #ddd; box-sizing: border-box; display: block; } .create button { background: #f1356d; color: #fff; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; }

  • @umarislam3315
    @umarislam33153 жыл бұрын

    Do we need state management system such as redux for modern reactjs apps?

  • @imgrori5435
    @imgrori54359 ай бұрын

    You're the goat

  • @BlackDev
    @BlackDev2 жыл бұрын

    remember when this looked foreign fells nice being able to read through so fluently humans are amazing

  • @dileepbannikatti7900
    @dileepbannikatti79003 жыл бұрын

    Please cover all scenario like check box radio button and check tree view and complex form validation and getting response ,api crud operation

  • @mohityadav21
    @mohityadav212 жыл бұрын

    3:05 Wohoo!! I love this small funny things 😍

  • @jochenade
    @jochenade Жыл бұрын

    Thanks!

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Thanks for your support Jochen, it's much appreciated!

  • @kashmirtechtv2948
    @kashmirtechtv29482 жыл бұрын

    Very useful

  • @tomasburian6550
    @tomasburian65502 жыл бұрын

    This is a good tutorial. But I would definitely need to know how to use buttons to set a boolean variable from false to true and vice versa.

  • @Mahmudulhasan-ts5hm
    @Mahmudulhasan-ts5hm3 жыл бұрын

    thanks brow

  • @kingsleymgbachi5662
    @kingsleymgbachi5662 Жыл бұрын

    which plugin do you use to get the html autocomplete?

  • @echo991
    @echo991 Жыл бұрын

    Is it necessary to set the input value to the dynamic title/author state? It doesn't appear to do anything.

  • @belafekete3125
    @belafekete31253 жыл бұрын

    Great tutorial! Thanks Ninja How can I use the public folder?

  • @RajvirSingh1313

    @RajvirSingh1313

    3 жыл бұрын

    It is just laying around there but it is handy when you have images and other static stuff that will be okay to be open to see by the public. src and other folders are kinda private or you could say the stuff that only you could see means the source code and one more thing I want to tell you that you should learn next.js too as it would be more good and robust combination with react. And you can learn more about next.js in this video kzread.info/dash/bejne/hZ-gxcGfgaXTk9Y.html&t. I hope I helped you , have a nice day

  • @eltoneycomerad8758
    @eltoneycomerad87583 жыл бұрын

    You are Great

  • @marek19922209
    @marek199222096 ай бұрын

    Instead of using routing from react we can use fetching from backend ?

  • @ridl27
    @ridl273 жыл бұрын

    ty

  • @cobycole23
    @cobycole232 ай бұрын

    Is it possible to set the state for all your inputs at once with the onchange function 🤔?

  • @nizarkadri3109
    @nizarkadri31092 жыл бұрын

    Can we use same id in different components , I mean if I have a in Home and in BlogDetails, is it valid?

  • @Sukaichae
    @Sukaichae9 ай бұрын

    woohoo!

  • @ibrahimkaarich2192
    @ibrahimkaarich2192 Жыл бұрын

    Hey M y prof i wish you're good and having a nice day please i have a question is this the full Tut of REACT i mean is will be more videos about REACT in this is playList

  • @timtech9361
    @timtech93612 жыл бұрын

    This is great and all. But what if you have a button that duplicates your Create component. Now you have two input Create components. Your state auto saves the input permanently from the first Create component. How do you reset the state to initial so we can have two Create components producing two DIFFERENT values on render?

  • @kushagramandal1501
    @kushagramandal15013 жыл бұрын

    Hello there, just wanted to know when this playlist will be completed? Awesome work BTW!

  • @TheRahulDBZ

    @TheRahulDBZ

    3 жыл бұрын

    you sound like my project manager

  • @kushagramandal1501

    @kushagramandal1501

    3 жыл бұрын

    @@TheRahulDBZ bruh😅

  • @prashanttanwar3261

    @prashanttanwar3261

    3 жыл бұрын

    @@TheRahulDBZ lol😂

  • @jamshoot6475
    @jamshoot6475 Жыл бұрын

    3:08 i really like that woohoo sound at 2x

  • @shadebinder3599
    @shadebinder3599 Жыл бұрын

    For some reason my button add blogs isn't in the center, its aligned with the left side of the boxes

  • @chanandlerbong6176
    @chanandlerbong61763 жыл бұрын

    so whenever any input field change happens whole form will be re rendered right? How to avoid that?

  • @mohamedchine-ky6yk
    @mohamedchine-ky6ykАй бұрын

    hey great video , btw is it bad if we get the value of the inputs directly with getelementbyid and we delete all the usestates like for example instead of this : [x,setx]=usestate("") {setx(e.target.value)}} /> we do this : x=document.getelementbyid(x); because tbh i dunno what's the use of the usestates with the form

  • @nihaljain246
    @nihaljain2463 жыл бұрын

    If the state variable is const, how can it be updated? I tried looking at the React docs for the useState hook but they didn't comment on this. I am just starting out with JS & React, so not sure if I was looking at the right places for the answer. It would be nice to know your comments on this, Shaun.

  • @codewithfarhad8594

    @codewithfarhad8594

    3 жыл бұрын

    state is not variable, we are destructing an array when we say const [x, y] = useState(""). and this is the regular behavior of const. const is storing reference to the array which can not be changed/reassigned. but we are not changing/reassigning the array here. We are just changing one of the values/variables stored in the said array, in this case, the value of x. Hope this helps. also if you want to study further just search on youtube for something like "difference between const, var, and let in javascript"

  • @Colstonewall

    @Colstonewall

    3 жыл бұрын

    If you look at this video (kzread.info/dash/bejne/lq55y8eQkbKwdZM.html) at about 4:14 it explains this fairly well. As Ali stated in his comment, this is an Array, and an Array (with Const) can be updated. The video doesn't talk about React, but about Const and when/if it can be updated.

  • @TheForestofNoobs
    @TheForestofNoobs4 ай бұрын

    "whooohouuu" :D

  • @aybak3k
    @aybak3k3 жыл бұрын

    const [title, setTitle] = useState('') const [body, setBody] = useState('') const [author, setAuthor] = useState('mario')

  • @user-xb7xp5kj9n
    @user-xb7xp5kj9n Жыл бұрын

    wooohooo

  • @user-yz6hr5wd9e
    @user-yz6hr5wd9e8 ай бұрын

    When i start type in the input i lost focus like input rerender and can type only once? Why is that?

  • @Invitamu
    @Invitamu Жыл бұрын

    i like your yuuhuu in the video HAHAHA

  • @anmolagarwal5952
    @anmolagarwal59523 жыл бұрын

    is it wrong to just trigger a onclick when submit button is clicked and just fetch value of all fields. This way we can escape all that react js extra redundant code.

  • @MohitRakhade
    @MohitRakhade3 жыл бұрын

    3:08 ooh wwwoh

  • @westernpigeon
    @westernpigeon2 жыл бұрын

    why are there no tutorials on class components? ANYWHERE on the internet?

  • @nikitalukashuk2978
    @nikitalukashuk29783 жыл бұрын

    I was a littile bit confused, because i haven't known that select has "value" property

  • @GabrielMartinez-ez9ue
    @GabrielMartinez-ez9ue3 жыл бұрын

    Quick question: if we set a state using const, how come later on we can update that value? const values cannot be updated

  • @kananabdlyv

    @kananabdlyv

    2 жыл бұрын

    We create state using const but the state is not a data type so it doesn't act like a simple value. Process is done by state not const directly

  • @vermusl6316

    @vermusl6316

    2 жыл бұрын

    Watch the useState video again, he already explained there

  • @hoanglongpham5907
    @hoanglongpham59073 жыл бұрын

    I have an idiot question but i need to understand? We use Hook to replace props and State in Class Component right? please explain for me, because i don't see Shaun talk about props and state?

  • @NetNinja

    @NetNinja

    3 жыл бұрын

    Hooks are another option that can be used to manage state as well as for other things. You can use the useState hook in a functional component for that component to have state, instead of relying on a class-based component for state. Props are not replaced at all by hooks, they are still very relevant and needed to pass data from one component into another. I covered props earlier in the course (lesson 11, 12, 13) :)

  • @hoanglongpham5907

    @hoanglongpham5907

    3 жыл бұрын

    @@NetNinja it means, we don't need create state when using hook like create state in class component, right ? so anyway, thank you a lots for replying me

  • @prashanttanwar3261

    @prashanttanwar3261

    3 жыл бұрын

    @@hoanglongpham5907 Hooks are used with functional components because functional components dont have state like class components do BUT by using hooks we can add state to our functional components.

  • @Eslam-ig2gf
    @Eslam-ig2gf Жыл бұрын

  • @Shou06
    @Shou063 жыл бұрын

    why dont you create a course for react along with nextjs in udemy

  • @NBA6Fan
    @NBA6Fan3 жыл бұрын

    Why do we need value then if we have state that gets the value onChange?

  • @marcisberzins7246

    @marcisberzins7246

    2 жыл бұрын

    That is because when you make UseState(initialValue) in form you see initial Value in that field.

  • @hughbillings8895
    @hughbillings88953 жыл бұрын

    .create { max-width: 400px; margin: 0 auto; text-align: center; } .create label { text-align: left; display: block; } .create h2 { font-size: 20px; color: #f1356d; margin-bottom: 30px; } .create input, .create textarea, .create select { width: 100%; padding: 6px 10px; margin: 10px 0; border: 1px solid #ddd; box-sizing: border-box; display: block; } .create button { background: #f1356d; color: #fff; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; }

  • @Hustada
    @Hustada2 жыл бұрын

    Is it possible to use "useState" one time for all inputs?

  • @oscaralderete8156

    @oscaralderete8156

    2 жыл бұрын

    Actually yes. You need to define an object variable for the new BLOG content, something like: const [blog, setBlog] = setState({ title: '', body: '', author: 'mario' }) then your inputs + textarea something like (take care that every element has a NAME attribute because this is how you can identify them later): mario yoshi now, you can set all of your elements with just one function, handleInput: const handleInput = (e) => { setBlog({ ...blog, [e.target.name]: e.target.value }) } a) You need to be familiarized with the JS concept of destructuring, so "...blog" means we're getting all properties of "blog" (title, body, author) in a new element, not "blog" per se because it's immutable. b) [e.target.name] is basically: title or author or body. You need to understand that (e) is the event on the form elements. "e.target" is every element per se: the input, the select and the textarea. Then, "e.target.name" is the name of the element, so it's respectively: title, author and body. c) e.target.value: is the current value of the input, the select and the textarea. To finalize, when you need to post, you don't have to declare a new variable as in the video, you just post "blog": fetch(url, { method: 'POST', headers: 'Content-Type: application/json', body: JSON.stringify(blog) }) React needs you're familiar with some kind of JS concepts like deconstructuring; in the same way you will use .map() a lot to mapping arrays to construct DOM elements. At the end it's just practice, practice and more practice.

  • @lonedruid3360
    @lonedruid3360 Жыл бұрын

    long live brother

  • @karthifairhawn9825
    @karthifairhawn98252 жыл бұрын

    3:08 fun Wo wo

  • @jalaliyev
    @jalaliyev3 жыл бұрын

    Thanks Shaun🖤. But I think those react concepts very very basic which you told about it, I don't understand what is the main difference those two tutorials. Please prepare modern Redux tutorial that cover of the all topics in the documentation

  • @sinnie.62.
    @sinnie.62.Ай бұрын

    It seems i am the only one who is not able to fetch data when clicking on the blog I even copy pasted from repo cause i was not able to find my mistake can some one help

  • @patshalaaa
    @patshalaaa Жыл бұрын

    3:08 😄

  • @jamshoot6475
    @jamshoot6475 Жыл бұрын

    woohoo

  • @Human_Evolution-
    @Human_Evolution-2 жыл бұрын

    Today I learned, body = bodeh.

  • @ahmedmustapha600
    @ahmedmustapha6007 ай бұрын

    pls where is the next tutorial and does it only stop at 27?