Skip to content

Commit

Permalink
utlizing callback refs for older versions of React
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-thrillist committed Oct 23, 2019
1 parent 62c0d96 commit ae27606
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion js/adslot.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export class AdSlot extends React.Component {
slotId: this.props.slotId || null,
className: this.props.className || '',
};
this.adElementRef = React.createRef ? React.createRef() : null;
this.adElementRef = React.createRef ? React.createRef() : (element) => {
this.adElementRef = element;
};
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion lib/adslot.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ function (_React$Component) {
slotId: _this.props.slotId || null,
className: _this.props.className || ''
};
_this.adElementRef = _react.default.createRef ? _react.default.createRef() : null;
_this.adElementRef = _react.default.createRef ? _react.default.createRef() : function (element) {
_this.adElementRef = element;
};
return _this;
}

Expand Down

0 comments on commit ae27606

Please sign in to comment.