Passing Data from Child to Parent Components in React

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ธ.ค. 2024

ความคิดเห็น • 32

  • @vishnuprakash8098
    @vishnuprakash8098 ปีที่แล้ว +1

    Explained very well, Thanks

  • @SagnikChakraborty-e3q
    @SagnikChakraborty-e3q 9 หลายเดือนก่อน +1

    Thank You Sir!! Was Stuck Hard Since Last 2 hrs And Then Found This Video

    • @KnowledgeKeen
      @KnowledgeKeen  9 หลายเดือนก่อน

      Happy that it helped you 😊

  • @Tejaswini-mm1yc
    @Tejaswini-mm1yc ปีที่แล้ว +1

    Thankyou so much for clear explanation..

    • @KnowledgeKeen
      @KnowledgeKeen  ปีที่แล้ว

      I am glad @Tejaswini you liked it. ☺️

  • @Chopkarmanoj
    @Chopkarmanoj 2 ปีที่แล้ว +1

    Great knowledge

    • @KnowledgeKeen
      @KnowledgeKeen  2 ปีที่แล้ว

      Thank you @manoj. I am glad you liked it 😊

  • @midhungk1930
    @midhungk1930 2 ปีที่แล้ว +1

    best video .. keep up the good work

  • @BHARATHKUMAR-kp9ig
    @BHARATHKUMAR-kp9ig 5 หลายเดือนก่อน +1

    great

    • @KnowledgeKeen
      @KnowledgeKeen  5 หลายเดือนก่อน

      Thank you Bharat

  • @blottolotto7648
    @blottolotto7648 2 ปีที่แล้ว +1

    ur the man. exactly what i was lookin for

    • @KnowledgeKeen
      @KnowledgeKeen  2 ปีที่แล้ว

      Thank you ☺️, I am glad you liked it.
      Please subscribe and share

  • @Human_Only_
    @Human_Only_ 2 ปีที่แล้ว +1

    so useful thanks a lot

    • @KnowledgeKeen
      @KnowledgeKeen  2 ปีที่แล้ว

      Glad it was helpful @Batool ☺️

  • @haiderjaafer8164
    @haiderjaafer8164 ปีที่แล้ว +1

    Great work... Can use this way with react-query

    • @KnowledgeKeen
      @KnowledgeKeen  ปีที่แล้ว

      Hey absolutely, react query is quite easy to use with this way too 😉

  • @snehalgawade-n9u
    @snehalgawade-n9u ปีที่แล้ว +1

    Hello, Thanks for covering this topic. Could you please explain after state lifting how to use that data in the parent component which we have received from child component?
    (Now we can print that data in the console but how to access that data outside the function?)

    • @KnowledgeKeen
      @KnowledgeKeen  ปีที่แล้ว

      Hellozzz,
      Check this video, this videos does have parent child data passing.
      th-cam.com/video/iCnAn45XL6A/w-d-xo.html
      And the easiest way to use the values post uplifting is save the same in local usestate variable.
      And thanks for the comment ☺️

  • @mhassankhan8677
    @mhassankhan8677 2 ปีที่แล้ว +1

    great tutorial , are you gonna make more videos?

    • @KnowledgeKeen
      @KnowledgeKeen  2 ปีที่แล้ว +1

      Your wish is my command, a video is just uploaded and live 😉

  • @MIXKNOWLEDGEbylohith
    @MIXKNOWLEDGEbylohith 2 ปีที่แล้ว +2

    I have multiple array of objects (data I use to create multiple charts) in separate js file so now I have to import individual chart data and use that data to create chart in new js file could you please help me or if I am doing anything wrong please correct me.

    • @KnowledgeKeen
      @KnowledgeKeen  2 ปีที่แล้ว

      Hi @LOHITH
      Quite an interesting question.
      Just have a couple of ideas on top of my head.
      Basic and most straightforward approach:- Create multiple components and separate JS files with data for each of those components. For e.g If you have a component for the current population with a chart, create files PopulationChartComponent.jsx and PopulationChartData.js respectively.
      A bit advanced and complex approach:- This would be a bit complex but a more interesting way to do it, would be to create one single component which will render any kind of chart according to the configuration and data we provide dynamically. This way you can save creating an enormous number of components and even any future chart(new requirement) would be easily integrated just by modifying simple configurations. In this too you can have multiple or single data files.
      Hope this helps 😊
      If you like this, kindly help us grow by sharing, subscribing, and hitting those likes

    • @MIXKNOWLEDGEbylohith
      @MIXKNOWLEDGEbylohith 2 ปีที่แล้ว

      @@KnowledgeKeen Thanks for the help

    • @KnowledgeKeen
      @KnowledgeKeen  2 ปีที่แล้ว

      @@MIXKNOWLEDGEbylohith You are welcome :)

  • @padmamuralikrishna1869
    @padmamuralikrishna1869 ปีที่แล้ว

    Can you make a video on passing similar props from parent to grandchild

    • @KnowledgeKeen
      @KnowledgeKeen  ปีที่แล้ว

      Hey @padmamuralikrishna1869 ,
      I have shown here how to pass data from Parent to Child ( th-cam.com/video/GVkYFFqQPtA/w-d-xo.html ) and passing data from Parent to Grandchild is done in a similar way.
      For e.g
      Parent.js
      const Parent = () => {
      const counter = 10;
      return
      }
      Child.js
      const Child = ({counter}) => {
      return {
      return Counter in GrandChild - {counter}
      }
      This concept is called Prop-Drilling and there are other ways to avoid this, which I will show in our other videos.

  • @ssshwanth
    @ssshwanth ปีที่แล้ว +1

    It is lifting state up

    • @KnowledgeKeen
      @KnowledgeKeen  ปีที่แล้ว

      Thank you for the comment, but I tend to keep it as simple as I can. But yes to those who will read this comment, yes it's also called as Lifting the state 🙂

    • @shaimeur
      @shaimeur ปีที่แล้ว

      @@KnowledgeKeen lifting the state up is involving moving the state from the child component to the parent component in your example you have used the concept of passing data from child to parent using a call back function and it's not the same think correct me if I made a mistake and thanks for the share!!

    • @KnowledgeKeen
      @KnowledgeKeen  ปีที่แล้ว

      @shaimeur actually it is 😊.
      The only way to lift the state is using a call back in this case.