Home avatar

David Feng

React Component Event Handlers

Note: I published this article on codeburst/Medium on 2017/07/30. It has received 18.3k views and 235 claps as of 2019/01/05.


What should be put in the onClick={…}?

This example is from React Docs, see it on codepen here.

In the Toggle class, a handleClick method is defined as an instance method, which changes the local state. In the render method, this.handleClick is passed to the button as an event handler. Finally, do not forget to bind this to handleClick in the constructor.

Hello World!

Happy New Year!

My current personal portfolio site hasn’t seen major changes since its inception about 1.5 years ago. I’ve been working as a software developer for a year and I think the site deserves a major upgrade.

I learned about static site generator a couple of days ago, and it seems like exactly what I need. Since I am learning golang, I decided to give Hugo a try. After going through Mike Dane’s Hugo tutorial (highly recommended. It seems that you don’t really need to know a lot of golang to use Hugo) and some setup, my new personal website is live at https://beta.davidfeng.us/ now! I plan to move it to https://davidfeng.us/ once I think it’s in a better shape.