REAL React Interview Questions - Live Coding

  Рет қаралды 63,810

Peter Elbaum

Peter Elbaum

Күн бұрын

Get the project code here: peterelbaum.gumroad.com/l/rea...
--
Follow Me Online Here:
🌏 My website/blog - peterelbaum.com
✉️ My newsletter (weekly on Sundays) - peterelbaum.com/subscribe/
🤓 My courses: peterelbaum.gumroad.com/
🗣 One-on-one mentoring - superpeer.com/peterelbaum
🐦 Twitter: / peterelbaum
💻 GitHub: github.com/elbaumpj
☎️ Office Hours: calendly.com/elbaumpj/saturda...
--
My gear:
Main Camera: amzn.to/2Tv1WBe
Tripod: amzn.to/2t570AH
External HD: amzn.to/2t1UphI
Memory card: amzn.to/2UEQfIn
Computer mic: amzn.to/2t7mUue
--
Who am I?
I'm Peter Elbaum, a software engineer living in Raleigh, North Carolina. I make videos about code, software engineering career development, and self improvement. I also have a newsletter (peterelbaum.com/subscribe) and tweet my thoughts on money, work, and being a great dev. Feel free to get in touch!

Пікірлер: 98
@thexpand
@thexpand Жыл бұрын
I believe there are a few things that I would have done differently and I am sure that implementing them could win you bonus points: 1. One of the wrapping elements can be replaced with a element and then the handleLogin can be passed to the onSubmit prop of the form. The then becomes a type="submit" button and doesn't need the onClick prop. 2. Probably it makes sense to clear the error if the user starts to change one of the fields again. 3. Also, I would use a nulll value when there is no error - it makes more sense for it to be null as this means that there is no error. An empty string for an error might indicate an error that doesn't have a description or some kind of an unknown error. I know that probably won't happen in real life, but it's a good practice to differentiate between null and an empty string. 4. setLoading(false) can go at the bottom, after the try/catch, instead of repeating it in both the try, and the catch. There's no need to place it inside. Alternatively, it can go in the finally clause of the try/catch block. 5. I personally take naming very seriously. disableButton sounds more like a name for a function that when called would disable the button. Probably would be better to call it isButtonDisabled.
@fedorlyust2080
@fedorlyust2080 11 ай бұрын
yeah you could also put the setLoading(false) at the finally section
@laurabennis3871
@laurabennis3871 5 ай бұрын
but you're not allowed to add any HTML elements, so I think it's the same with updating existing ones?
@theboyIncomfortzone
@theboyIncomfortzone 3 ай бұрын
I guess that's why it said "Not allowed adding HTML Elements"
@craigmars1393
@craigmars1393 Жыл бұрын
This is so helpful!! I’m busy completing an advanced React course and this is such a great way to measure where I’m currently at! Please don’t stop making these vids, it has so much value!
@PeterElbaum
@PeterElbaum Жыл бұрын
Glad it was helpful! You got this!
@adeleke5140
@adeleke5140 Жыл бұрын
Thank you Peter. I tried solving the challenge before you did it and was able to solve it in 16min 30s. I had a bunch of hiccups which slowed me down but I'm glad I was able to solve it.
@drewbird87
@drewbird87 2 жыл бұрын
After doing a few take-homes and live interviews lately; I've thought that it would make a cool youtube series/channel to collect them from devs doing interviews. Maybe with two formats. One video where it's new to the dev and then a second video with a "designed" solution. Cool to see a little peek of your freelancing progress too! 👍🏼👍🏼
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Interesting thought! May have to implement something like that...
@gshankar125
@gshankar125 Жыл бұрын
really good content Peter..it is helping me a lot to learn front end technology because you deal with concepts and understanding more than routine tutorial walkthrough
@galkoaz8408
@galkoaz8408 8 ай бұрын
Well done Man can you upload more React Interview Questions like that but more harder?
@ProwlerDigital
@ProwlerDigital 2 жыл бұрын
Thank you! This is exactly the type of react content I’ve been looking for. Appreciate it
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Glad it was helpful! :)
@mc-qf4bp
@mc-qf4bp Жыл бұрын
Instead of adding setLoading false in two places in both the try and the catch, you could've added a finally block and added it to that.
@blue-jk2qu
@blue-jk2qu 2 жыл бұрын
thank you! this is super helpful :) especially the trick with 'disabledButton' variable, I've been using conditional rendering based on 'loading' value, but that's a lot more neat, thanks again!
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Glad it helped! :)
@DrumAdrian16
@DrumAdrian16 7 ай бұрын
great video!
@bastienv6233
@bastienv6233 Жыл бұрын
great, I've go over the 15min but I got it. If you have more like this, it will be so helpful! thank u very much for sharing
@joaquindicio8874
@joaquindicio8874 Жыл бұрын
I've been looking for a video like this, thanks
@PeterElbaum
@PeterElbaum Жыл бұрын
Glad you liked it!
@arcosd63
@arcosd63 Жыл бұрын
Awesome exercise Peter, thanks a lot!
@sarvarsaidov7058
@sarvarsaidov7058 2 жыл бұрын
great content, more interview live challenges like this are really helpful👍
@PeterElbaum
@PeterElbaum 2 жыл бұрын
You got it! :)
@michaelmarafino8664
@michaelmarafino8664 2 жыл бұрын
Keep them coming Peter!
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Thanks for your encouragement! :)
@noorb374
@noorb374 Жыл бұрын
Thank you ... please make more videos on real react coding challenges
@mukhtartanimugarba9527
@mukhtartanimugarba9527 2 жыл бұрын
Good one! Thank you for the content.
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Glad you enjoyed it! :)
@tylermyers8735
@tylermyers8735 Жыл бұрын
great video man thank you. all well and good!
@PeterElbaum
@PeterElbaum Жыл бұрын
Glad it helped!
@benatakaan613
@benatakaan613 2 жыл бұрын
Thank you. Your content is amazing! 🤗
@PeterElbaum
@PeterElbaum 2 жыл бұрын
You're very welcome! Thanks for your support :)
@setarose366
@setarose366 Жыл бұрын
So good! Thank you@
@aabhasjain96
@aabhasjain96 Жыл бұрын
Hey Peter, Thanks a lot for making this video. I would request you to please release more such type of live coding vide. It is very useful. Once again Thank you so much.
@PeterElbaum
@PeterElbaum Жыл бұрын
Will do - thanks for watching!
@richardramirez5746
@richardramirez5746 10 ай бұрын
good to see these videos
@rylsdark
@rylsdark 11 ай бұрын
this was a quite chill and easy challenge, managed it in roughly 8 mins (including fixing the dependency tree which was outdated for today's standard due to node major version change) for those wondering, just input these commands on first install if you're running node v17+: >npm i >npm audit fix --force >npm update then just do the normal npm start and it should run fine. cool stuff that i find better than what was shown on vid: i did the button disabled by: which is way quicker than declaring a whole ass const. and the div was only shown by doing this: {error !== '' ? {error} : null} which is the most appropriate way of doing what was asked.
@go_better
@go_better 5 ай бұрын
Thanks a lot. Dope, spot on, practical.
@PeterElbaum
@PeterElbaum 4 ай бұрын
You're welcome!
@r1makan
@r1makan Жыл бұрын
Hey! Thank you for uploading this, very useful :) Could you please tell me where to find such challenges?
@chrisdietrich1533
@chrisdietrich1533 2 жыл бұрын
absolutely fantastice content. please make more
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Thank you! You got it :)
@kwanyeetan5872
@kwanyeetan5872 10 ай бұрын
Hi, thanks for the video. I saw that you have 4 declaration of useState(). Would it be recommended that I use useReducer() for this problem instead?
@emmanuellmiqueletti7029
@emmanuellmiqueletti7029 Жыл бұрын
I really like this exercise.
@oakleyorbit
@oakleyorbit 2 жыл бұрын
That was great!!
@PeterElbaum
@PeterElbaum 2 жыл бұрын
thanks!! :)
@rahimnealyakoob5968
@rahimnealyakoob5968 Жыл бұрын
useState seems unnecessary for the email and password? why can't you just access the email and password inputs from the html element on button click?
@thatrandomperson3968
@thatrandomperson3968 Жыл бұрын
This is fairly simple and I can probably do it in that amount of time, but I'm sure to fail if you give me time limit and have someone watch me code. 😢
@danieltkach2330
@danieltkach2330 2 жыл бұрын
Awesome stuff! The zooming is completely unnecessary and super dizzling hahaha but cool stuff absolutely, thanks! And by the way, what software do you use to do that? Can it write on screen while you are recording?
@PeterElbaum
@PeterElbaum 2 жыл бұрын
will keep in mind for the next one. software = Loom (loom.com)
@muradqumizakis8428
@muradqumizakis8428 Жыл бұрын
this is amazing
@PeterElbaum
@PeterElbaum Жыл бұрын
thanks :)
@zathkal4004
@zathkal4004 2 жыл бұрын
SetError("error, something went wrong") could be a quick interview fix I guess... Awesome video mate , thanks
@PeterElbaum
@PeterElbaum 2 жыл бұрын
You're very welcome! :)
@kuntalbhattacharyya7614
@kuntalbhattacharyya7614 2 жыл бұрын
Great video ❤️
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Thank you!!
@kevinka99
@kevinka99 Жыл бұрын
interview for entry or junior right
@waleedtariq109
@waleedtariq109 Жыл бұрын
Amazing
@huseynfy
@huseynfy Жыл бұрын
great!! thanks!
@PeterElbaum
@PeterElbaum Жыл бұрын
You're very welcome! :)
@malemyengkhom56
@malemyengkhom56 2 жыл бұрын
Want more of this type of video
@PeterElbaum
@PeterElbaum 2 жыл бұрын
You got it! :)
@prajnaprabhu286
@prajnaprabhu286 2 жыл бұрын
Great, Thank you
@PeterElbaum
@PeterElbaum Жыл бұрын
Welcome 😊
@jordanspano
@jordanspano Жыл бұрын
How is the disableButton variable constantly being updated on input change?
@Raganaki1
@Raganaki1 Жыл бұрын
Everything in component's body gets executed again on each state change
@marekvozarik5441
@marekvozarik5441 Жыл бұрын
Is this junior dev interview?
@asagiai4965
@asagiai4965 5 ай бұрын
Thankfully this is just a question. For me i won't recommend it on production. Since if i'm correct you are re-running the state every time. Also technically you can set the initial state of error to null or something.
@jakubacki4319
@jakubacki4319 Жыл бұрын
Hooks are still cool? Or something changed?
@carlosarreola275
@carlosarreola275 Жыл бұрын
how do you start the project on the browser?
@PeterElbaum
@PeterElbaum Жыл бұрын
npm start :)
@bopatzable
@bopatzable 8 ай бұрын
what is a COOING challenge?
@busyrand
@busyrand Жыл бұрын
Impressive.
@jewymchoser
@jewymchoser Жыл бұрын
Why am I the only one who loves Blazor?! It's React but statically typed in so no more imports, boiler-plate, intellisense is kosher, etc.. I feel so alone :(
@dock1804
@dock1804 2 жыл бұрын
Just a little suggestion.. Maybe do a little less zooming in and out of the screen, it can get somewhat frustrating especially on higher playback speeds.
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Thanks for the feedback, will take this into account on the next tutorial video. Cheers!
@aguamenti1175
@aguamenti1175 Жыл бұрын
Just do final{setLoading(false)}
@GuessWho189
@GuessWho189 Жыл бұрын
grreat
@amandhamanda9822
@amandhamanda9822 2 жыл бұрын
You have used disabled attribute and setting it using variable...cant we use something like events.target.disabled = true?...what is the difference in these 2 approaches
@RakeshSahu-cr9ks
@RakeshSahu-cr9ks Жыл бұрын
Bro, I think the reason he did it this way is because of its simplicity, the question had conditions where the button should be disabled, so he just created a variable with those conditions and passed it to already existing property (disabled) of the button. Its just simpler than having a eventlistener and passing the conditions into it, dont you think so? Im still learning so i might be wrong here
@LBF_NotGnome
@LBF_NotGnome Жыл бұрын
useState causes re-renders on every keystroke for email and password. Wouldn't useRef be better in this example over useState? Also, if keeping handleLogin inside component like that, I would place it inside a useCallback since you're re-rendering and redefining the function on every keystroke.
@vorche_
@vorche_ Жыл бұрын
it doesnt matter react is faster than you think
@caseyvandyke7051
@caseyvandyke7051 Жыл бұрын
One of the criteria is you can't use refs.
@tenzl
@tenzl Жыл бұрын
why not just put useCallBack and useMemo in everything? it's important to know when it's necessary. React is very fast and these small micro performance gains isn't worth the overhead of looking at all the useMemo and useCallBack and the potential bugs that might accompany it.
@gpudoctor
@gpudoctor Жыл бұрын
The question is fundamentally flawed, the correct html would be to encapsulate both inputs in a form element, and add an onSubmit event handler instead of onClick
@asagiai4965
@asagiai4965 5 ай бұрын
This. The problem is the interview question not the applicant. This is why the interviewer should know what they are questioning.
@samuelgunter
@samuelgunter Жыл бұрын
these are all things you learn day one
@the3dcapybara
@the3dcapybara Жыл бұрын
Well, this takes like 20 minutes from me...
@Dan-cz1ut
@Dan-cz1ut Жыл бұрын
i don't know what position you have actually interviewed for, to get this kind of problem set, but from my experience, real life interviews are nothing like this. This is basic beginner stuff, that a technically versed guy, that played with React for a weekend would nail. Once again, not trying to be negative, just sharing my personal experience, both as interviewee and interviewer.
@PeterElbaum
@PeterElbaum Жыл бұрын
There's a lot of ways to interview, so it would make sense to me that our experiences aren't perfectly aligned. This was a second step technical screening - there were some algorithms questions included with it, but I didn't include those as I'm just focusing on React here.
@Lucas-jb8ce
@Lucas-jb8ce Жыл бұрын
I like your solution but it is very verbose. You took way longer to solve it, not only because you're obviously explaining what you're doing (which is expected in an interview), but because you're defining a lot of useStates. I merged them all down into three single useStates and was able to do it extremely fast: const [{ email, password }, setInput] = useState({ email: '', password: '' }); const [loading, setLoading] = useState(false); const [{ hasError, errorMessage }, setError] = useState({ hasError: false, errorMessage: '' }); Then I handle the error like this instead: function handleLogin() { setLoading(true); login({ email, password }) .then(() => { alert('Successfully logged in'); setLoading(false); }) .catch((e) => { setError({ hasError: true, errorMessage: e.message }); setLoading(false); }); } So notice how everything is just bundled up together so I can use them as I please. Now I despise JavaScript so I would've preferred for it to be in TypeScript haha.
@sdmit2000
@sdmit2000 Жыл бұрын
His code is actually more readable and good luck doing that in 15 mins
@KL4NNNN
@KL4NNNN Жыл бұрын
Why inputs attributes are inside parenthesis {} and double quotes "". SHouldn't they be inside double quotes only ""?
@nandoomb
@nandoomb Жыл бұрын
Great man! Just a tip, I think you could use finally clause on try catch to setLoading() in it. So, it will be called every time independent of the result
@thebattinson1278
@thebattinson1278 Жыл бұрын
nice catch !
@nandoomb
@nandoomb Жыл бұрын
@@thebattinson1278 thanks man 👊🏻
@AminSani
@AminSani 2 жыл бұрын
Great, thank you
@PeterElbaum
@PeterElbaum 2 жыл бұрын
Glad you liked it! :)
REAL Front End Interview Questions - Whiteboard
9:38
Peter Elbaum
Рет қаралды 30 М.
The React Interview Questions You need to Know
21:29
CoderOne
Рет қаралды 16 М.
Каха с волосами
01:00
К-Media
Рет қаралды 5 МЛН
顔面水槽がブサイク過ぎるwwwww
00:58
はじめしゃちょー(hajime)
Рет қаралды 75 МЛН
How did CatNap end up in Luca cartoon?🙀
00:16
LOL
Рет қаралды 5 МЛН
This is a good beginner React interview challenge question
30:38
Web Dev Cody
Рет қаралды 70 М.
HARD React Interview Questions (3 patterns)
6:10
Peter Elbaum
Рет қаралды 104 М.
Coding Interview with Dan Abramov
58:20
Ben Awad
Рет қаралды 636 М.
React Interview Questions 2020 (7 Questions)
21:59
Coding With Chaim
Рет қаралды 110 М.
I loved solving this junior react interview challenge
26:02
Web Dev Cody
Рет қаралды 150 М.
This is a good intermediate react interview challenge
38:30
Web Dev Cody
Рет қаралды 51 М.
REAL Front End Interview Questions (from three companies)
11:01
Peter Elbaum
Рет қаралды 56 М.
Phone charger explosion
0:43
_vector_
Рет қаралды 48 МЛН
С Какой Высоты Разобьётся NOKIA3310 ?!😳
0:43
What % of charge do you have on phone?🔋
0:11
Diana Belitskay
Рет қаралды 241 М.
🤏 САМЫЙ ТОНКИЙ гаджет #Apple! 🍏
0:29
Яблочный Маньяк
Рет қаралды 645 М.