Don’t use inline functions or bind() in React ref callbacks
Kwindla Hultman Kramer
834

The recommended pattern is for callback refs to have minimal side-effects, and to use React lifecycle hooks to read the new values if you need them. componentDidMount and componentDidUpdate would be the ones to use.

You might also want to look into the new createRef API coming in React 16.3: https://deploy-preview-587--reactjs.netlify.com/docs/refs-and-the-dom.html

Like what you read? Give Alex Krolick a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.