Skip to content

Instantly share code, notes, and snippets.

@conorhastings
Created January 20, 2017 03:28
Show Gist options
  • Save conorhastings/860280bec0c1030ada36818b84baf622 to your computer and use it in GitHub Desktop.
Save conorhastings/860280bec0c1030ada36818b84baf622 to your computer and use it in GitHub Desktop.
react refs
/* node will be null */
function Input() {
return <input />;
}
function InputContainer() {
return <div><Input ref={node => console.log(node)} /></div>;
}
/* node will be vnode instance */
import React from "react";
import { render } from "react-dom";
class Input extends React.Component {
render() {
return <input />
}
}
function InputContainer() {
return <div><Input ref={node => console.log(node)} /></div>;
}
render(<InputContainer />, document.getElementById('app'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment