Skip to content

Instantly share code, notes, and snippets.

@wesleytodd
Created April 8, 2017 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesleytodd/04f70d66d730c874c9d67302d6a4a3ad to your computer and use it in GitHub Desktop.
Save wesleytodd/04f70d66d730c874c9d67302d6a4a3ad to your computer and use it in GitHub Desktop.
var oldRefs = parseInt(React.version.split('.')[0], 10) < 14;
function refCompatibilitySet (refName) {
if (oldRefs) {
return refName;
}
return function (ref) {
this['__ref' + refName] = ref;
};
}
function refCompatibilityGet (component, refName) {
if (oldRefs) {
return component.refs[refName] && component.refs[refName].getDOMNode();
}
return component['__ref' + refName];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment