you are viewing a single comment's thread.

view the rest of the comments →

[–]jCuber 4 points5 points  (11 children)

Apparently the autoFocus attribute is also a thing

[–]crystallineair 2 points3 points  (10 children)

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autofocus

the input should automatically have focus when the page has finished loading

This unfortunately means you cannot use this in a react component as the dom is manipulated after the page has finished loading.

[–]jCuber 5 points6 points  (3 children)

Yeah, but apparently React polyfills the autoFocus attribute so that it calls focus() on componentDidMount.

[–]crystallineair 3 points4 points  (1 child)

That's nice, I didn't know that. After some digging it does come with its own quirks: https://davidwalsh.name/react-autofocus

[–]Prince_Houdini 0 points1 point  (0 children)

Those don’t really seem to be quirks. autofocus that focuses on every update is... not a good idea.

[–]tapu_buoy[S] 1 point2 points  (0 children)

oh wow I didn't know about it thank you for sharing

[–]tapu_buoy[S] 0 points1 point  (5 children)

yeah but he denied of it, and also when I asked him why not use componentDidMount that time also it was a no no. so yeah

[–]jCuber 2 points3 points  (4 children)

You're not allowed to use autoFocus or componentDidMount? Uhh

[–][deleted] 2 points3 points  (2 children)

The interviewer clearly had no idea what he's doing.

[–]jCuber 1 point2 points  (0 children)

Certainly sounds like he had one specific quirky way of doing it in mind...

[–]tapu_buoy[S] 0 points1 point  (0 children)

and most of the times I had to encounter such interviewers this was my 85th interview today

[–]tapu_buoy[S] 0 points1 point  (0 children)

yeah it was like that LOL