flyingant / react-scroll-to-component

smooth scrolling to react component via reference.
https://flyingant.github.io/react-scroll-to-component/
168 stars 27 forks source link

Getting a warning accessing findDOMNode inside render #10

Open sakin opened 7 years ago

sakin commented 7 years ago

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; }}

`

zentuit commented 7 years ago

that looks correct... where are you calling findDOMNode?

sag1v commented 6 years ago

this is coming from here i think. So if you call scrollToComponent inside your render you will get this warning.

Mahdiyeh commented 3 years ago

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" />; }