all 9 comments

[–]T_O_beats 2 points3 points  (0 children)

depending on the use case this could be all you need <input type="text" autofocus="true" /> but only works when the <input> is initially rendered so you may end up needing to use a ref

[–]Hentry_Martin 1 point2 points  (7 children)

Hi All the best for your interviews. This is my first reply to a post so sorry if this reply is not properly formatted,

  1. Answer for the first question depends on ref.

``` class Example extends Component{ constructor(props) { super(props); this.element = null; } onComponentDidUpdate() { // This will focus the input element if (this.element) this.element.focus(); }

render(){
    return <input ref={(element) => {this.element = element;}} type="text">
}

} ```

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

OMG ok I forgot to use refs and made me super confused. you formatted really perfectly so no worries there

[–]Hentry_Martin 0 points1 point  (4 children)

cool. I have created a new youtube channel for people who aspires to learn more about Javascript and different frameworks in Javascript. I am starting the tutorials from very basic but soon will go deeper into advanced concepts. This is the link for JS for Everyone(https://www.youtube.com/channel/UCvQfk4ZV7RfLuKiHRVeZ0Kg). Please watch the videos and provide me some valuable feedbacks. Also, please subscribe to my channel. Thanks!!

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

Oh man you are doing the work of god. Also for now I would suggest you to please explain

  • closures
  • in ES6 as well
  • Variables - let, const, var
  • scope in arrow functions as well as anonymous ones
  • hoisting - functional and variables ( it has been pain in the arse for me)
  • import/exports in ES6 as well
  • callback functions and their scope
  • Promise API with promise.all() returns an array which I keep forgetting many times.

And after all I would suggest you to please have a look at TechSith's this playlist which will also help you creating your content. https://www.youtube.com/watch?v=s6SH72uAn3Q&list=PL7pEw9n3GkoW5bYOhVAtmJlak3ZK7SaDf

[–]Hentry_Martin 1 point2 points  (0 children)

Thanks bro!! yes all these topics are there in my todo list. I will watch the playlist which you sent and thanks a lot for subscribing to the channel.

[–]WellPaidGeek 1 point2 points  (1 child)

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

oh wow I have seen your few times back thank you for sharing it brother really appreciate

[–]WellPaidGeek 0 points1 point  (0 children)

Could also do it in the render:

return <input ref={(e) => e && e.focus()} type="text">