Skip to content

findDOMNode returns null in ref callback when rendering multiple times #4651

@menelaos

Description

@menelaos

I'm trying to use the ref attribute as described here:
https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute

Unfortunately, React.findDOMNode(component) sometimes returns null, when
React.render is called multiple times.

MWE:

import React from "react";

class View extends React.Component {
  render () {
    return (
      <div>
        <input type="text"
               ref={c => console.log(React.findDOMNode(c))} />
      </div>
    );
  }
}

function render () {
  React.render( <View />
              , document.getElementById("container")
              );
}

setInterval(render, 1000); // Alternating beween null and <input ...>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions