react-scroll-to-component
react-scroll-to-component copied to clipboard
Getting a warning accessing findDOMNode inside render
Warning: {COMPONENT} is accessing findDOMNode inside its render(). render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.
I could be doing it wrong, my ref looks like this:
<tr ref={row => { this.row = row; }} >
that looks correct... where are you calling findDOMNode
?
this is coming from here i think.
So if you call scrollToComponent
inside your render
you will get this warning.
For me the following code made this error:
ReactDOM.findDOMNode(this.refs.textInput).focus();
I fixed the issue with this:
this.refs.textInput.focus();
My code looks like this:
constructor(props) { super(props); this.textInput = null; }
render() { return <input ref="textInput" />; }