Miron Machnicki
1 min readMar 1, 2017

--

Solution was to define method as arrow function so

handleClick = event => ...<Component onClick={ this.handleClick } ... />

not

<Component onClick={ () => ... } ... />

I agree that passing arrow function directly into property is not good because of example which you have mentioned. Nice tip.

Setting arrow function as method should trigger another render for PureComponent.

UPDATE: I have checked again my code and see, that the last example is not good. Mean partial application

onKeyPress={ this.handleKeyPress(item) }

will always trigger render for PureComponent. Will update article soon. Thanks!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Miron Machnicki
Miron Machnicki

Written by Miron Machnicki

Full-stack developer - react.js, node.js, serverless. @machnicki

Responses (1)

Write a response