Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

fixes react StrictMode deprecation warnings #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions dist/SAlertContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@
function SAlertContent(props) {
_classCallCheck(this, SAlertContent);

return _possibleConstructorReturn(this, (SAlertContent.__proto__ || Object.getPrototypeOf(SAlertContent)).call(this, props));
var _this = _possibleConstructorReturn(this, (SAlertContent.__proto__ || Object.getPrototypeOf(SAlertContent)).call(this, props));

_this.currentAlertElemWrapper = _react2.default.createRef();
return _this;
}

_createClass(SAlertContent, [{
key: 'handleCloseAlert',
value: function handleCloseAlert() {
var closingTimeout = void 0;
var alertId = this.props.id;
var currentAlertElem = _reactDom2.default.findDOMNode(this);
var currentAlertElem = this.currentAlertElemWrapper.current;
var animationClose = function animationClose() {
currentAlertElem.style.display = 'none';
_sAlertStore2.default.dispatch({ type: 'REMOVE', data: { id: alertId } });
Expand All @@ -125,8 +128,10 @@
this.alertAudio && this.alertAudio.load();
}
}, {
key: 'componentWillMount',
value: function componentWillMount() {
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;

var beep = this.props.beep;
var condition = this.props.condition;
if (beep && typeof beep === 'string') {
Expand Down Expand Up @@ -154,12 +159,6 @@
this.alertAudio.load();
this.alertAudio.play();
}
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;

if (typeof this.props.timeout === 'number') {
this.closeTimer = setTimeout(function () {
_this2.handleCloseAlert();
Expand Down Expand Up @@ -189,8 +188,10 @@
var handleClose = this.handleCloseAlert.bind(this);
var contentTemplate = this.props.contentTemplate || _SAlertContentTmpl2.default;
var customFields = this.props.customFields || {};
var condition = this.props.condition;
var ref = this.currentAlertElemWrapper;

return _react2.default.createElement(contentTemplate, { classNames: classNames, id: id, styles: styles, message: message, handleClose: handleClose, customFields: customFields });
return _react2.default.createElement(contentTemplate, { ref: ref, classNames: classNames, id: id, styles: styles, message: message, handleClose: handleClose, customFields: customFields, condition: condition });
}
}]);

Expand Down
1 change: 1 addition & 0 deletions dist/SAlertContentTmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
SAlertContentTmpl.propTypes = {
id: _propTypes2.default.string.isRequired,
classNames: _propTypes2.default.string.isRequired,
condition: _propTypes2.default.string.isRequired,
styles: _propTypes2.default.object.isRequired,
message: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]).isRequired,
handleClose: _propTypes2.default.func.isRequired,
Expand Down
12 changes: 6 additions & 6 deletions lib/SAlertContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import SAlertContentTmpl from './SAlertContentTmpl';
class SAlertContent extends React.Component {
constructor(props) {
super(props);
this.currentAlertElemWrapper = React.createRef();
}
handleCloseAlert() {
let closingTimeout;
const alertId = this.props.id;
const currentAlertElem = ReactDOM.findDOMNode(this);
const currentAlertElem = this.currentAlertElemWrapper.current;
const animationClose = () => {
currentAlertElem.style.display = 'none';
sAlertStore.dispatch({type: 'REMOVE', data: {id: alertId}});
Expand All @@ -33,7 +34,7 @@ class SAlertContent extends React.Component {
// stop audio when closing
this.alertAudio && this.alertAudio.load();
}
componentWillMount() {
componentDidMount() {
let beep = this.props.beep;
let condition = this.props.condition;
if (beep && typeof beep === 'string') {
Expand Down Expand Up @@ -61,8 +62,6 @@ class SAlertContent extends React.Component {
this.alertAudio.load();
this.alertAudio.play();
}
}
componentDidMount() {
if (typeof this.props.timeout === 'number') {
this.closeTimer = setTimeout(() => {
this.handleCloseAlert()
Expand All @@ -88,9 +87,10 @@ class SAlertContent extends React.Component {
const handleClose = this.handleCloseAlert.bind(this);
const contentTemplate = this.props.contentTemplate || SAlertContentTmpl;
const customFields = this.props.customFields || {};
const condition = this.props.condition
const condition = this.props.condition;
const ref = this.currentAlertElemWrapper;

return React.createElement(contentTemplate, {classNames, id, styles, message, handleClose, customFields, condition});
return React.createElement(contentTemplate, {ref, classNames, id, styles, message, handleClose, customFields, condition});
}
}

Expand Down
Loading