Solving a practical intermediate react interview challenge

  Рет қаралды 86,599

Web Dev Cody

Web Dev Cody

Жыл бұрын

💬 Discord / discord
🔔 Newsletter eepurl.com/hnderP
📁. GitHub github.com/codyseibert
My VSCode Extensions:
- theme: material community high contrast
- fonts: Menlo, Monaco, 'Courier New', monospace
- errors: Error Lens
- extra git help: Git Lens
- tailwind css intellisense
- indent rainbow
- material icon theme
- prettier & eslint
- ES7+ React Snippets

Пікірлер: 112
@pepperdayjackpac4521
@pepperdayjackpac4521 Жыл бұрын
I watched this video entirely in my bed, and now I plan on practicing this for myself once I get out of bed. This was very interesting and helpful.
@manusartifex3185
@manusartifex3185 10 ай бұрын
LMAo me too
@timibolu
@timibolu 2 ай бұрын
Same here
@csy897
@csy897 Жыл бұрын
Thanks so much! I was about to give up leetcode because I didn’t understand the need for data structures beyond maps and arrays like trees, stacks, heaps as a frontend dev. But you just showed an elegant solution with recursion. Gives me good motivation to study more!
@BigKaTrob
@BigKaTrob Жыл бұрын
Nice, I like the way you handled the depth. This could also be done in CSS with a clever use of a sibling selector but I like the way you've done it here with js a little better.
@TheLorepRocks
@TheLorepRocks Жыл бұрын
I had to do a similar code challenge, but also I had to add an input next to every element in the tree after pressing the enter key the child should be added to the right tree level. I haven't received any feedback but looking at this video makes me feel like I did a good job! Thank you! :)
@skapha
@skapha Жыл бұрын
WDJ this is awesome! Please more of this kind of content, more challenges (intermediate to advanced)! The Essence!
@MrAlexVelik
@MrAlexVelik Жыл бұрын
Thanks for the great content, as always, Cody!
@internetexplorer7880
@internetexplorer7880 Жыл бұрын
Thanks 🙏🙏... This is exactly what i was gonna work on and your way is so much simpler
@renatoAllArt
@renatoAllArt Жыл бұрын
tks dude, u help a lot with this code challenges series, i've never had think to use recursive code to render a component.
@ChillAutos
@ChillAutos Жыл бұрын
Nice video. This gives me a lot of confidence if this is intermediate / advanced. Im only about a year into my first dev job but I could pretty easily come up with a solution for this.
@BrooUmad
@BrooUmad Жыл бұрын
I love watching you code man. I interned at a place last year using React and I was really bad at that. Watching you is making me want to try again with front end.
@WebDevCody
@WebDevCody Жыл бұрын
Give it another try!
@aamiramin6112
@aamiramin6112 Жыл бұрын
This is so informative and real-world use cases like recursion, rendering, etc. Thanks alot for sharing.
@WebDevCody
@WebDevCody Жыл бұрын
You're very welcome!
@divyuesharma
@divyuesharma Жыл бұрын
Loving this series and get learn something new before going to bed. 👍🏽
@Thassalocracy
@Thassalocracy Жыл бұрын
11:26 A suggestion, the element might work perfectly as it has its own dropdown. You can nest the children inside without having to depend on a toggle state and semantic HTML is a plus. Anyway, thank u so much for showing us how to tackle an intermediate react challenge. 😀
@captainnoyaux
@captainnoyaux 3 ай бұрын
Great suggestion, and it seems supported everywhere. You had something like that in mind ? function Entry({name, children}: TEntry) { return {children ? {name} {children && {children?.map(value => )}} : {name}} } I tested it and it does the job, no need for a button and such, great thinking !
@setarose366
@setarose366 Жыл бұрын
These are the best! Please keep these coming!
@JoaoVitor-gm2yf
@JoaoVitor-gm2yf 10 ай бұрын
5:58 I think it doesnt really need to keep track of depth, just use margin instead of padding, so it renders the indentation in relation to the parent element
@rowancode
@rowancode 4 ай бұрын
This is actually great
@brayancuenca6925
@brayancuenca6925 Жыл бұрын
Dude, love your videos. I always watch them before I go to bed to wake up first thing in the morning and practice on them 🤙
@WebDevCody
@WebDevCody Жыл бұрын
That’s a true fan!
@thewatcher3564
@thewatcher3564 6 ай бұрын
Appreciate this video! Just been given a project at work to design a section based hierarchy like this (ex. 1.0, 1.1, 1.1.2, …). Now just need to think about how to create subsections under the parent that line up with backend
@theantibeta
@theantibeta Жыл бұрын
You don't need depth prop, with ol > li and padding does works
@nikhilbhagat3832
@nikhilbhagat3832 7 ай бұрын
Amazing explanation
@mtiganik
@mtiganik 6 ай бұрын
Button was not needed I think, could do the trick
@jowarnis
@jowarnis Жыл бұрын
Awesome :D really enjoyed this!
@bradaa2053
@bradaa2053 9 ай бұрын
for the styling of the button you can use something like -> button { all: unset; cursor: pointer; } then it will remove all the default stylings
@anil4real_
@anil4real_ Жыл бұрын
more of these kind of videos please!
@mirozxl
@mirozxl Жыл бұрын
Never was a person to comment on a youtube video, like or share it. But these types of coding for intermediate react js interview qsn made me do all those things.
@Eddie4k
@Eddie4k Жыл бұрын
This was super helpful!
@mandalorian99
@mandalorian99 7 ай бұрын
im a mid full stack dev and still great to see someone eleses thinking process. Grat content!
@eshw23
@eshw23 6 ай бұрын
Hey cody nice video! Next time for future code challenges can you maybe just give a bigger in depth explanation of the problem, with more examples, I didnt understand the problem at first or what it should look like(maybe im stupid😀), Thanks!
@gabrielfono844
@gabrielfono844 11 ай бұрын
very good exercice thanks a lot
@lofibeats2344
@lofibeats2344 4 ай бұрын
This is some kind of content that is not available and really fun to watch
@honournosa9129
@honournosa9129 11 ай бұрын
Awesome video
@livetowin-pj7yl
@livetowin-pj7yl Жыл бұрын
I don't even know where to start with kind of problem. Thanks for enlightening me. Though I know recursion and why you used it here, is it required to know DSA at this point?
@Daddyjs
@Daddyjs Ай бұрын
Beautiful
@user-pi2zd4xj8z
@user-pi2zd4xj8z 27 күн бұрын
Many things to learn here
@memeproductions4182
@memeproductions4182 Жыл бұрын
Little late lol, but you don't need to add 10 padding * depth for esch node, since every node has already the cumulative padding of the previous levels. Otherwise your children will have always increasing padding compared to the previous ones
@rishilapsiwala9503
@rishilapsiwala9503 7 ай бұрын
Hi Cody, I tried to build a tree using recursion and I was successful, however when I implemented a search algorithm to filter in the tree. I faced this invariant violation- rendered fewer hooks than expected. and now I am not able to move forward
@medAmineRg
@medAmineRg 7 ай бұрын
thank you
@chezanagrofarm153
@chezanagrofarm153 Жыл бұрын
thanks really helpful. for this video do you practice it beforehand or straight live coding? thats awesome if it is live coding
@WebDevCody
@WebDevCody Жыл бұрын
I just start with the idea and start coding
@markopolo2224
@markopolo2224 Жыл бұрын
very interested in this
@EvilTim1911
@EvilTim1911 7 ай бұрын
This was actually pretty straightforward, I expected it to be harder for an intermediate challenge. I feel like my imposter syndrome often acts up but most of these challenges end up being a breeze. Time to start applying for more senior roles I guess.
@flyinglow
@flyinglow Жыл бұрын
I think one optimization... it's possible without the nested mapping. Remove the initial mapping and pass 'entry.children' directly into then mapping there, while checking 'entry.children && ' to trigger the recursive. any who, thank you for this challenge! watched the video and jumped on the computer like "YOU CAN RECURSIVELY RENDER?!"
@Ebiko
@Ebiko Жыл бұрын
this is interesting. Just recently i coded a Dynamically increasing tree. - to allow fetching additional folder data from subfolders and not loading everything at once. Used a "Path" Variable, splitted it by "/" and used a recursive function to recursivly call itself until the splitted path is empty, returning the data. It looks super weird in code. But i think i got a quite good solution.
@xrli
@xrli Жыл бұрын
How can we adapt this solution to keep track of which sub-folder has been opened, and keep that state persistently, even though the parent folder has been closed and then reopened?
@TheSourLemonz
@TheSourLemonz Жыл бұрын
good one
@dedavai
@dedavai 4 ай бұрын
Can bypass much of the react complexity by using and HTML tags
@yahwehagape
@yahwehagape 2 ай бұрын
Instead of mapping over files in App component, just have a root Entry and when you nest it in App no need to reimplement mapping there.
@ahmadhariri1092
@ahmadhariri1092 Жыл бұрын
It would be more easier if you used the details tag of html, don't you think?
@poloiaish6281
@poloiaish6281 11 ай бұрын
Where do you get these react challenges? Or do you just randomly think about it or came across it
@WebDevCody
@WebDevCody 11 ай бұрын
I just make them up
@gabrielfono844
@gabrielfono844 11 ай бұрын
I have a year 2months of experience as full stack developer and I just applied for a job that required 3 years of experience as frontend developer the phone screen was ok and they move me to the next role how do I prepare it in one week ? I will appreciate any advice here
@WebDevCody
@WebDevCody 11 ай бұрын
Idk that’s a hard one. Fake it till you make it
@IgnitedIce81
@IgnitedIce81 11 ай бұрын
Don't forget to add some maximum depth to prevent infinite recursion
@golfgrab9481
@golfgrab9481 Жыл бұрын
how to setup auto complete optional chaining?
@golfgrab9481
@golfgrab9481 Жыл бұрын
4:40
@emmanuellmiqueletti7029
@emmanuellmiqueletti7029 11 ай бұрын
how to do you switch to the browser behind the vs code and the mouse stays on the same position?
@WebDevCody
@WebDevCody 11 ай бұрын
do you mean the built in virtual monitors mac os provides?
@Daddyjs
@Daddyjs 3 ай бұрын
What if files was just an array of objects instead of files being an object with the children key ?
@Isfean
@Isfean Жыл бұрын
I aspire to someday be a Frontend Developer (never applyed to jobs cause i didn't study cs and feel like I'm not enough).. and when I saw that this is Intermediate I feel like I'm already a "Senior" cause this looks pretty easy to me.. So my question is, how much should I ask for when I get an offer? :)
@WebDevCody
@WebDevCody Жыл бұрын
The intermediate is all relative. Your starting rate would probably be the average for your country and area for a junior dev if you never had a coding job. Again, these challenges are just to verify you can at least code and problem solve, there would still be a lot of questions and discussions that might happen before or after any coding challenge.
@mythicalwraith7026
@mythicalwraith7026 Жыл бұрын
How does the isExpanded && () work?
@WebDevCody
@WebDevCody Жыл бұрын
If isExpanded is truthy it’ll render the next part out to the screen
@dailyDiary213
@dailyDiary213 7 ай бұрын
From.where do u find these questions is there any website for daily react js challanges
@WebDevCody
@WebDevCody 7 ай бұрын
I usually make them up
@dailyDiary213
@dailyDiary213 7 ай бұрын
@@WebDevCody will u make more like 30 days challenge from biggner to advance please it will help a lot for interview for a Fresher like me
@quterma
@quterma Жыл бұрын
nice
@kalahari8295
@kalahari8295 Жыл бұрын
Nested drop-down list?
@Jupiter5001
@Jupiter5001 8 ай бұрын
That's called accordion and it is an easy one
@Paxters_
@Paxters_ Жыл бұрын
Is vite better than yarn? or whats the diference between them?
@WebDevCody
@WebDevCody Жыл бұрын
They are different tools. Vite is similar to webpack and it’s used for bundling your code. Yarn is similar to npm and is used for managing project dependencies
@artistry7919
@artistry7919 Жыл бұрын
There's an html tag called details that would've been better suited for this
@Genocidechaos
@Genocidechaos Жыл бұрын
Hi where do you get your practice questions from?
@WebDevCody
@WebDevCody Жыл бұрын
Other people and I make some up
@gorkemeldeniz9579
@gorkemeldeniz9579 Жыл бұрын
i think there is a tiny bug in your isExpanded logic.If u click the button all other files expanding ,in my opinion expanding state must be unique for all parent files and toggle it individually.
@kristopherlawson3893
@kristopherlawson3893 Жыл бұрын
I don’t see the bug, joi isn’t expanded when node_modules is expanded
@gorkemeldeniz9579
@gorkemeldeniz9579 Жыл бұрын
​@@kristopherlawson3893 yes you are right there is no bug at all cause of the every time new component render and it has a prop individually
@alexluu3615
@alexluu3615 Жыл бұрын
@@gorkemeldeniz9579 would you please go into more detail? I initially thought the same thing as your first comment.
@gorkemeldeniz9579
@gorkemeldeniz9579 Жыл бұрын
@@alexluu3615 if the parent component share expand state as a prop to children it effects all other child components but he make the statement in the children component therefore it does not effect each other all states are individual
@alexluu3615
@alexluu3615 Жыл бұрын
@@gorkemeldeniz9579 thank you for your response and helping clear the confusion. best of luck to you and your coding journey!
@warzonehacks4915
@warzonehacks4915 5 ай бұрын
Can someone tell me where he used the recursion?
@lazerhawk2192
@lazerhawk2192 5 ай бұрын
The function entery has a component entry that references the entry function. You can see that entry references itself. This is recursive as it will continue to call entry on the stack until there is no more children, which is our base case, and then we exit returning entry.
@rowancode
@rowancode 4 ай бұрын
Is this consider intermediate/advanced? I believe there must be harder questions than this that are for begginers
@cszqravr
@cszqravr 3 ай бұрын
Yeah, this definitely is an very, very easy one. We would only use such an example if the candidate is super nervous to hand them a free win and move on to an actual coding interview. Even with that being the case, the shown solution definitely would be docked some points
@jggabayno
@jggabayno Жыл бұрын
hello bro, my question is out of the topic but does RTK still makes sense with NextJS 13 app directory? or any state management you suggest to be use?
@WebDevCody
@WebDevCody Жыл бұрын
I like jotai right now. Super simple to setup and share state between components.
@simonli8889
@simonli8889 Жыл бұрын
13 min video to make that, probs a good hour for me😂 (I'm a beginner btw)
@CraigClayton-bk3ze
@CraigClayton-bk3ze Жыл бұрын
Typescript does seem a lot of extra boilerplate and work
@fen1x591
@fen1x591 Жыл бұрын
In small project sure it might seem so, but as it gets bigger advantages are far more visible
@WebDevCody
@WebDevCody Жыл бұрын
It’s useful, I promise
@CraigClayton-bk3ze
@CraigClayton-bk3ze Жыл бұрын
The problem is that I see a lot of videos where there is all this extends, typeof, generic, , and it all looks confusing. A good example would be the youtuber Matt Pocock, he is supposed to be a typescript wizard and he does all this stuff with it and it is a little daunting to us beginners
@emreozgun3846
@emreozgun3846 Жыл бұрын
@@CraigClayton-bk3ze Most of the 'generic sorcery' makes the code really hard to read for TS beginners but it shouldn't discourage you from utilizing structural typing in your codebase.
@fen1x591
@fen1x591 Жыл бұрын
​@@CraigClayton-bk3ze ​Well ts typesystem is basically a new language on top of a javascript so you simply have to learn it to understand more complex stuff with generics
@dcknature
@dcknature Жыл бұрын
Get well soon, Web Dev Junkie 🙏🤗. Thanks for the video 🍉😉👍!
@djoezi3662
@djoezi3662 Жыл бұрын
Amazing! Just speak a bit slowly and up please. Not only native english speakers watch you!
@lillenk125
@lillenk125 Жыл бұрын
123
@ahmadmuslih
@ahmadmuslih Жыл бұрын
Bro can you make better title?
@McProski
@McProski Жыл бұрын
what's wrong with the title lol?
@mjohnson510
@mjohnson510 Жыл бұрын
I think he's distrete with his titles to prevent people from easily searching for the solution when prepping for coding interviews.
@WebDevCody
@WebDevCody Жыл бұрын
What would you recommend the title being?
@WebDevCody
@WebDevCody Жыл бұрын
@@mjohnson510 actually i didn’t think of that, but that’s a good reason. I figured having “intermediate interview challenge” would bring more views than “building a file tree viewer in react”. People like prepping for interviews, they don’t care about building a tree browser 😂
@mjohnson510
@mjohnson510 Жыл бұрын
@@WebDevCody I actually got the File Structures problem from Atlassian lol. But, I like your titles. I actually search React Intermediate/Advanced interview problems then the actual specifics
@algorithmictoolbox6856
@algorithmictoolbox6856 3 ай бұрын
This is what i was asked yesterday, and i solved it after the interviewer was gone
@Bempus
@Bempus Жыл бұрын
I just wanted a simple mockup tree from an acual folder and came up with this in PowerShell, you do however need to pipe it to "Convertto-Json -depth 100" after to format it correctly. function Get-HTMLFileTree($dir) { $folder = Get-Item $dir $html = [System.Collections.ArrayList]@() $obj = [PSCustomObject]@{ name = $folder.name } if ($folder.Mode[0] -ne 'd') { $html.Add($obj) | Out-Null; return $html } $obj | Add-Member -MemberType NoteProperty -Name children -Value ([System.Collections.ArrayList]@()) $children = $folder | Get-ChildItem foreach ($child in $children) { $obj.children.Add((Get-HTMLFileTree -dir $child.FullName)) | Out-Null } $html.Add($obj) | Out-Null return $html } (ex. Get-HTMLFileTree -dir . | Convertto-Json -depth 100 | Set-Clipboard)
My best advice for finishing projects
8:41
Web Dev Cody
Рет қаралды 10 М.
Monster dropped gummy bear 👻🤣 #shorts
00:45
Yoeslan
Рет қаралды 12 МЛН
This is a good beginner React interview challenge question
30:38
Web Dev Cody
Рет қаралды 70 М.
I'm definitely using this library for all server actions now
5:31
Web Dev Cody
Рет қаралды 13 М.
Mid-level React Interview
46:08
Justin Lawrence
Рет қаралды 53 М.
Coding Interview with Dan Abramov
58:20
Ben Awad
Рет қаралды 636 М.
How I would learn to code (if I could start over)
10:52
PIRATE KING
Рет қаралды 1,2 МЛН
Setup VSCode like a senior React developer
13:43
Cosden Solutions
Рет қаралды 43 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 131 М.
A subscriber was asked these junior interview questions
18:58
Web Dev Cody
Рет қаралды 37 М.
How to NOT Fail a Technical Interview
8:26
Fireship
Рет қаралды 1,3 МЛН
Monster dropped gummy bear 👻🤣 #shorts
00:45
Yoeslan
Рет қаралды 12 МЛН