Performance penalty of creating handlers on every render with react-hooks

前端 未结 5 2139
野的像风
野的像风 2020-12-03 16:54

I\'m currently very amazed about the use cases of the new react hooks API and what you can possibly do with it.

A question that came up while experimenting was how e

5条回答
  •  猫巷女王i
    2020-12-03 17:32

    You are right, in large applications this can lead to performance issues. Binding the handler before you pass it to the component avoids that the child component might does an extra re-rendering.

    
    
    

    Both are equivalent. The e argument representing the React event, while with an arrow function, we have to pass it explicitly, with bind any arguments are automatically forwarded.

提交回复
热议问题