announcekit-react
Advanced tools
Comparing version
@@ -19,3 +19,7 @@ import * as React from "react"; | ||
name: string; | ||
widgetInstance: any; | ||
constructor(props: any); | ||
isEquivalent(a: any, b: any): boolean; | ||
shouldComponentUpdate(props: any): boolean; | ||
componentDidUpdate(prevProps: any): void; | ||
componentDidMount(): void; | ||
@@ -22,0 +26,0 @@ loaded(): void; |
@@ -39,2 +39,27 @@ "use strict"; | ||
} | ||
AnnounceKit.prototype.isEquivalent = function (a, b) { | ||
var aProps = Object.getOwnPropertyNames(a); | ||
var bProps = Object.getOwnPropertyNames(b); | ||
if (aProps.length !== bProps.length) { | ||
return false; | ||
} | ||
for (var i = 0; i < aProps.length; i++) { | ||
var propName = aProps[i]; | ||
if (a[propName] !== b[propName]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
AnnounceKit.prototype.shouldComponentUpdate = function (props) { | ||
return !this.isEquivalent(this.props, props); | ||
}; | ||
AnnounceKit.prototype.componentDidUpdate = function (prevProps) { | ||
if (!this.isEquivalent(this.props, prevProps)) { | ||
if (this.widgetInstance) { | ||
this.widgetInstance.destroy(); | ||
this.loaded(); | ||
} | ||
} | ||
}; | ||
AnnounceKit.prototype.componentDidMount = function () { | ||
@@ -77,2 +102,3 @@ if (!window["announcekit"]) { | ||
var ann = window["announcekit"]; | ||
_this.widgetInstance = _widget; | ||
if (_this.props.catchClick) { | ||
@@ -110,3 +136,3 @@ var elem = document.querySelector(_this.props.catchClick); | ||
AnnounceKit.prototype.render = function () { | ||
return React.createElement("a", { href: "#", style: { display: "inline" }, className: this.selector ? this.selector.slice(1) : "" }); | ||
return (React.createElement("a", { href: "#", style: { display: "inline" }, className: this.selector ? this.selector.slice(1) : "" })); | ||
}; | ||
@@ -113,0 +139,0 @@ return AnnounceKit; |
{ | ||
"name": "announcekit-react", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Use AnnounceKit widgets in your React App", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
13841
15.39%309
25.61%