How to build a Recursive React Component

Поділитися
Вставка

КОМЕНТАРІ •

  • @srymisclick
    @srymisclick 6 місяців тому +216

    To understand recursion, first you have to understand recursion.

    • @yeikiu
      @yeikiu 6 місяців тому +15

      Agreed, but both come right after understanding recursion

    • @abnormal6376
      @abnormal6376 6 місяців тому

      Very recursive.

    • @jasonennis4905
      @jasonennis4905 6 місяців тому

      Pretty much 😅😂

    • @Ra5h3d_
      @Ra5h3d_ 6 місяців тому

      I see what you did there 😅

    • @srinivaskoruprolu7638
      @srinivaskoruprolu7638 5 місяців тому

      How to explain recursion without explaining it 😅

  • @nagasrinivasvinodkumarpand9309
    @nagasrinivasvinodkumarpand9309 6 місяців тому +77

    I am totally blown.. became an instant fan of this guy.. Love the teaching.. simplicity.. elegance.. ticked all the things.. don't remember when I was so impressed with just one tutorial video.. hats-off!!

    • @no1_of_note
      @no1_of_note 6 місяців тому +5

      Yes. The videos from this secret love child of Bradley Cooper and Hugh Jackman do indeed slap.

    • @akg530
      @akg530 6 місяців тому

      I can’t stop staring at his face; too hot to handle AND he’s smart? we need more from him

    • @magnuserikkeenrobot1117
      @magnuserikkeenrobot1117 6 місяців тому

      i agree, he is the best!

    • @GordonChil
      @GordonChil 6 місяців тому

      *insert “Phrasing” Archer gif here*

  • @azkaarkhatib
    @azkaarkhatib 6 місяців тому +32

    Loved how you made your way to the solution step by step by writing the duplicate code first and then separating that into its component, then fixing the data structure, then the types, then the naming.
    This not only shows me how to implement the topic but also how I should be thinking if I run into duplicate code.

    • @samselikoff
      @samselikoff  6 місяців тому +8

      Glad to hear the approach landed! I always like to motivate every step because in the real world you should only use a new approach or tool if you have a specific pain point it addresses 👍

  • @extremus7673
    @extremus7673 6 місяців тому +9

    Crazy that I was building something similar at the moment, got somewhat stuck trying to think of a solution to do recursion, and this videos drops. Thank you so much!

  • @privateaccount2607
    @privateaccount2607 3 місяці тому

    What an amazing video! This guy just made me the fan. The way he proceeds from scratch to the last was just incredible. Hats off to you.

  • @tomershechner
    @tomershechner 4 місяці тому

    You're insanely talented, your teaching skills are top-notch.

  • @Szchmausser
    @Szchmausser 5 місяців тому +1

    Wow! what a talent you have for explaining! I managed to make it work, and because I understood the whole process I was able to adapt it to my system, where I needed to show some data with a hierarchical structure. Thank you very much!

  • @club4796
    @club4796 5 місяців тому +1

    -enjoying 100% and understanding 10%

  • @Rajdidnotdie
    @Rajdidnotdie 5 місяців тому

    This is sooooo good , your style of explaining is very elegant.

  • @danieladionisio5165
    @danieladionisio5165 5 місяців тому

    I loved how he explained this topic. Thanks for your approach! Now it seems more easy.

  • @mikeom1308
    @mikeom1308 5 місяців тому

    Wow he has made this look so easy, while explaining it so clearly and concisely, was struggling with Typescript, now I think I understand it.

  • @jamesgulland
    @jamesgulland 6 місяців тому +1

    Incredible video, simply explained. I’ve always heard about recursion but never had to apply it, this gave me the light bulb moment! Biggups.

  • @amanjha3346
    @amanjha3346 5 місяців тому

    Just straight to the topic no intro no fancy drama..this is lit 🔥 awesome

  • @laptopuser5198
    @laptopuser5198 6 місяців тому

    This is one of the best channels for learning react.

  • @ilirbajrami2902
    @ilirbajrami2902 6 місяців тому

    Welcome back Sam! The world is safer when you are around :) Thanks for this one also! Very nice way to build a documentation page navigation.

  • @otaviomonteagudo6757
    @otaviomonteagudo6757 6 місяців тому

    I was looking into building something like this, this video was great. You've earned yourself a lifetime subscription for buildio .

    • @samselikoff
      @samselikoff  6 місяців тому

      I truly appreciate the support

  • @Serkan0kur
    @Serkan0kur 6 місяців тому

    Great tutorial. It is not just presenting the final code, Sam demonstates how a programmer can move forward building and cleaning the code. Thank you Sam, for sharing the video. I will be waiting forward for more mindblowing contents.

  • @shoebuddin2533
    @shoebuddin2533 6 місяців тому +1

    What an amazing explanation of data structure usage with react components. It is literally the best explanation I've seen since i started learning react👍👍💖

  • @fireball7456
    @fireball7456 6 місяців тому

    I am so glad I stumbled upon this channel, that was so interesting to learn about! That was also so incredibly smooth and well edited. If you did this in one take, that's unbelievable.

  • @MrBumbo90
    @MrBumbo90 4 місяці тому

    Very good tutorial. I used recursion in a threejs react component a while back and this is a good use case for it. Thanks for the effort.

  • @ganeshbabu8263
    @ganeshbabu8263 6 місяців тому

    The Way you are using your editor is wonderful.

  • @maddbzfan234
    @maddbzfan234 6 місяців тому +2

    i never knew about the react recursive components before, but this video cleared most of my concepts, and it was so cool 🙌

  • @WahiduzzamanHridoy
    @WahiduzzamanHridoy 5 місяців тому

    I had done kind of the same thing a year ago for a project of mine. I really like the way you explained it. Thank you for sharing.

  • @yashsolanki069
    @yashsolanki069 6 місяців тому

    Absolute 💎 and loved the react conf presentation as well !!!

  • @tritc
    @tritc 5 місяців тому

    This tutorial video is amazing, and I am grateful for your help! Keep the good work bro!

  • @jitxhere
    @jitxhere 6 місяців тому

    It was almost magical as you progressed. Really like your teaching style. Wow I am amazed

  • @thabosiphiwemngoma1859
    @thabosiphiwemngoma1859 Місяць тому

    I am yet to see a cooler react tutorial. Its so cool and useful

  • @ratishjain2718
    @ratishjain2718 6 місяців тому

    This guy deserves more subs man

  • @alexandroarauco8097
    @alexandroarauco8097 6 місяців тому

    Amazing tutorial, explanation is so clear.
    Thanks.

  • @alexg7282
    @alexg7282 6 місяців тому

    Nice tutorial. This video's format is just perfect. Thanks a lot !

  • @MohamedElguarir
    @MohamedElguarir 6 місяців тому

    maan, great to see you back on YT!
    Love your videos 🙏🙌

  • @olawumisegun5898
    @olawumisegun5898 6 місяців тому +1

    Thanks Sam for all you do for the community. I would love to propose a tutorial on Radix UI, hopefully a responsive landing page or more

    • @samselikoff
      @samselikoff  6 місяців тому

      Thanks for the kind words! I made a Radix UI course earlier this year but it was more focused on microinteractions - can you give some more examples of which primitives from Radix you'd like to see more of?

    • @olawumisegun5898
      @olawumisegun5898 6 місяців тому

      @@samselikoff Thanks alot for your response. Layout design showcasing the use of grid and flexbox would be fun to watch

    • @fernandocanizo8267
      @fernandocanizo8267 6 місяців тому

      @@samselikoff I would like to know your opinion about the need for something like Shadcn/UI and alikes. Does it really provide value over plain Radix? Or anybody could just style Radix with ease?
      BTW, great video, pretty clear and to the point without missing anything.

  • @rajat_kaushik
    @rajat_kaushik 5 місяців тому

    This was so well delivered!

  • @alarsut
    @alarsut 6 місяців тому +1

    thanks for your video sam! I am looking forward to your new course.

  • @dev-akeel
    @dev-akeel 6 місяців тому

    I can't stop myself:
    Really Really Amazing 👏

  • @UdaySagar
    @UdaySagar 6 місяців тому

    thats soo awesome ddude , i struggled to make one for one of my projects few days ago but not able to .. thanks .

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 6 місяців тому

    Thank you so much sam, very helpful content, please keep posting videos

  • @BeeBeeEight
    @BeeBeeEight 5 місяців тому

    Very nice tutorial, I subbed immediately. Just like to point out that outside of react, recursion can also be used to calculate factorials, permutations, summation series, etc due to the repetitive nature of these calculations. It helps to understand recursion in a general sense so we know when to apply recursive patterns.

  • @carefulcode
    @carefulcode 6 місяців тому

    Beautiful stuff man. Thanks for this!

  • @nourigadjanibrahim
    @nourigadjanibrahim 5 місяців тому

    Great!!! We are waiting for a sequel to this file management tutorial

    • @samselikoff
      @samselikoff  5 місяців тому

      Thanks! What would you like to see?

    • @nourigadjanibrahim
      @nourigadjanibrahim 5 місяців тому +1

      @@samselikoff Connection to a database. (CRUD) Automation of folder creation and file saving.

    • @samselikoff
      @samselikoff  5 місяців тому

      @@nourigadjanibrahim Cool idea! Would you want to see the folder/file creation actually happen on the filesystem, or in a database with virtual files/folders?

  • @Rico-cp4xp
    @Rico-cp4xp 6 місяців тому

    The drought is over! Love your videos. Never heard of this concept before!

  •  6 місяців тому

    Thanks for sharing. This is completely about the case which I was assigned.

  • @K.Huynh.
    @K.Huynh. 5 місяців тому

    Thank you for sharing.
    This video helps me a lot.

  • @parkerrex
    @parkerrex 6 місяців тому +1

    Fantastic explanation. Also lots of little workflow tricks in here. I didn't realize there were 3 ways to use double cursors. Also never used emmet->remove tag!

  • @zeeshan4341
    @zeeshan4341 6 місяців тому

    I have seen this example before. But loved your video 😊

  • @edgarasben
    @edgarasben 6 місяців тому

    Thanks Sam! Love learning small powerful nuggets like this:)

  • @voinbobar
    @voinbobar 6 місяців тому

    Simple yet very informative video! Love it.

  • @Bread-vk8fl
    @Bread-vk8fl 5 місяців тому

    This is amazing!! wow, i'm impressed

  • @magnuserikkeenrobot1117
    @magnuserikkeenrobot1117 6 місяців тому

    absolutely amazing. i love your style and your videos always amaze me. keep it coming! i recommend creating some shorter videos which shows some tips and tricks

  • @D_bugit
    @D_bugit 6 місяців тому

    Just looking at this gives me an idea... Thanks ❤❤

  • @adiMallya
    @adiMallya 6 місяців тому

    Damn. You just made it look less overwhelming!

  • @karsongrady
    @karsongrady 6 місяців тому

    Sheesh, that is a beautiful implementation! Thanks, Sam!

  • @CodeWithRomaen
    @CodeWithRomaen 6 місяців тому

    missed your videos. absolutely love your videos. You are such a good educator

  • @kaushalkumar6666
    @kaushalkumar6666 6 місяців тому

    Awesome stuff explaining style is preety great and clear

  • @wandenreich770
    @wandenreich770 6 місяців тому

    Very informative..turns out I could have used recursion in my project

  • @leulfanuel3550
    @leulfanuel3550 6 місяців тому

    Great video, please keep em coming. We are learning a lot 🎉

  • @IDOLIKIofficial
    @IDOLIKIofficial 6 місяців тому

    Quality content, very clean stuff!

  • @EissonAlipio
    @EissonAlipio Місяць тому

    amazing bro, thanks for sharing ❤

  • @MrAlao675
    @MrAlao675 6 місяців тому

    This is very clean and too awesome ❤❤❤

  • @sanjaytomar135
    @sanjaytomar135 5 місяців тому

    it was great, thank you, and do make more videos like this

  • @collinsk8754
    @collinsk8754 6 місяців тому

    Great stuff! Very clear!

  • @풍월상신
    @풍월상신 6 місяців тому

    This is amazing!! Thank you Sam.

  • @osamammursleen
    @osamammursleen 6 місяців тому

    Thanks. Its super fun to learn.

  • @shanehoban
    @shanehoban 6 місяців тому

    Great example of recursive components.
    The next task you might want to consider is to have recursive components that effect state, where the page/top level state is changed, and also the specific child component state is changed (effecting it's child component) - which will cause too many re-renders if not handled correctly.
    Not to give away the answer, but imagine a top level state that is an object, where the child components have a button that can add new levels to this state onto themselves. The state must be pushed upwards in this case, and passing keys won't work in a multi level nested object (in an onChange for example).
    The task therefore is to have the state reflected correctly without causing too many re-renders.
    Happy to walk through in more detail, might be nice for another video for you.

    • @samselikoff
      @samselikoff  6 місяців тому +1

      Yeah that sounds like a fun one! In general I don't like to think about re-renders in React until they cause a problem (and I think others should do the same). There's plenty of examples where the approach here will work just fine for. Also I'm hopeful the React Compiler will make that sort of perf optimization unnecessary.

  • @regilearn2138
    @regilearn2138 6 місяців тому

    It went like breeze, appreciate it we need react with SOLID principle please

  • @anshikgupta2993
    @anshikgupta2993 5 місяців тому +1

    Can we add check boxes beside each node and add selection in parent children selection

  • @limitlesskode
    @limitlesskode 5 місяців тому

    This is genius. Subscribed

  • @LHQQ888
    @LHQQ888 6 місяців тому

    Thanks Sam !

  • @shubhamdas6519
    @shubhamdas6519 3 місяці тому

    Thanks for the video sir.

  • @nick-ui
    @nick-ui 6 місяців тому

    Lessgooo, Sam's comeback!

  • @technosujeet
    @technosujeet 2 місяці тому

    Nice explanation

  • @3Shivs
    @3Shivs 4 місяці тому

    recently for drag & drop I handled it in unelegant way, am going replace this with recursion.
    Thank you so much man,

  • @akshatdubey4421
    @akshatdubey4421 6 місяців тому

    Great explanation!

  • @HeyNoah
    @HeyNoah 6 місяців тому

    Dude, this is so cool!

  • @akshaysingh5933
    @akshaysingh5933 6 місяців тому

    Thank you for sharing! The feature is great. Could you also consider adding drag-and-drop functionality for folders and files? That would be fantastic!

  • @faruksardar8829
    @faruksardar8829 6 місяців тому

    Finally Sam is back 💖💖

  • @luizvictoriobaptistaneto1561
    @luizvictoriobaptistaneto1561 6 місяців тому

    That was awesome!

  • @IkraamDev
    @IkraamDev 6 місяців тому

    Great video as always!

  • @abhisflyingsoon
    @abhisflyingsoon 6 місяців тому

    this is super helpful, thx :D need more pls

  • @dgiri2333
    @dgiri2333 6 місяців тому

    Nice it's help change browser UI Build Idea changes soon

  • @mudgalz
    @mudgalz 5 місяців тому

    You've got new subscriber

  • @habtesellasiefii
    @habtesellasiefii 6 місяців тому

    keep posting bro I like your vids

  • @lih4553
    @lih4553 6 місяців тому

    Finally more vids 💪

  • @thanyaniinnocent940
    @thanyaniinnocent940 5 місяців тому

    Him: How cool is this
    This is so cool 💥💥🔥🔥

  • @acloudonthebluestsky9687
    @acloudonthebluestsky9687 6 місяців тому

    You are the GOAT sir ,3

  • @scotle9901
    @scotle9901 6 місяців тому

    It's awesome. Thank bro.🎉

  • @roid1510
    @roid1510 6 місяців тому

    damn i never thought rendering a Component in itself was possible. On the other hand why wouldnt it work? its just a function. :D
    learned a new thing today. Thank you!

  • @sivabalanmurugavel6913
    @sivabalanmurugavel6913 5 місяців тому

    Absolute 💎

  • @maxwebstudio
    @maxwebstudio 6 місяців тому

    Great video

  • @andresgutgon
    @andresgutgon 6 місяців тому

    Awesome video 🎉

  • @ekekw930
    @ekekw930 6 місяців тому +2

    How would you go about keeping the state of each open folder so on a page refresh the same ones stay open?

  • @gmg15
    @gmg15 6 місяців тому

    awesome, it would be cool to see nodes having memory of its own collapse state

    • @samselikoff
      @samselikoff  6 місяців тому +2

      Yeah I thought about this as well - I think I'd reach for a useLocalStorage hook for each node and use a single Set with the node's `id` as a key to pull this off

  • @swrserwerwr9137
    @swrserwerwr9137 3 місяці тому

    you are genius

  • @yashone7
    @yashone7 5 місяців тому

    Sweet jesus, I didn't know rendering trees was this simple, or was it made simpler by sam?? Lovely stuff

  • @flaviojunior4408
    @flaviojunior4408 6 місяців тому

    Awesome tutorial man! One way the code could be improved is to make a component for a Folder and other for a File (kinda like a strategy). And since the collapsible state matters only for folders you could avoid creating unnecessary state for files

    • @samselikoff
      @samselikoff  6 місяців тому

      Thanks! I actually think it's cleaner with one component - my general rule is to not extract until it's painful. I really appreciate how easy React makes it to incrementally add complexity & I fully embrace it in my work! If it started to get crazy you could definitely abstract but in my experience it's best to hold off abstracting as long as possible.

  • @shafu_xyz
    @shafu_xyz 6 місяців тому

    so neat!

  • @igorgoncalves5691
    @igorgoncalves5691 6 місяців тому

    Nice explanation, thnks

  • @jackjsy
    @jackjsy 6 місяців тому +1

    Built something like this a few times and you gota be careful on very deep tree's when using state, lots of re-rendering! hopefully react compiler will solve all of that soon!

  • @rachitshrivastava4583
    @rachitshrivastava4583 5 місяців тому +1

    Hey Sam, loved this explanation and your way of teaching things step by step. I’ve been learning and using vim from past few months… may I know what shortcut did you use at 18:56 for renaming “Folder” to “Node” everywhere in the file? Also are you using VS code with vim enabled or the terminal with NVIM or something ?

    • @samselikoff
      @samselikoff  5 місяців тому +1

      Thanks for the kind words! The rename is a VSCode feature, you can find it as "Rename symbol" in the command palette or with the F2 shortcut (which is how I do it). It renames things semantically so it understands scope and everything. Definitely one of my fave features and I use it all the time.
      I use VS Code with the vim extension: marketplace.visualstudio.com/items?itemName=vscodevim.vim

  • @aliveyeyt4136
    @aliveyeyt4136 6 місяців тому +1

    i used this before in one of my react job interviews. pretty cool!