From 80e3216f0bce242ed67cd3c7500887a759539fad Mon Sep 17 00:00:00 2001 From: Mushfiq Mashuk Date: Thu, 8 Sep 2022 18:46:06 +0600 Subject: [PATCH] Changed componentWillReceiveProps to UNSAFE_componentWillReceiveProps --- dist/react-stars.js | 4 ++-- example/bundle.js | 6 +++--- src/react-stars.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/react-stars.js b/dist/react-stars.js index bcb0ede..9eb466d 100644 --- a/dist/react-stars.js +++ b/dist/react-stars.js @@ -86,8 +86,8 @@ var ReactStars = function (_Component) { }); } }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(props) { + key: 'UNSAFE_componentWillReceiveProps', + value: function UNSAFE_componentWillReceiveProps(props) { this.setState({ stars: this.getStars(props.value), value: props.value, diff --git a/example/bundle.js b/example/bundle.js index 31b3fb6..966c003 100644 --- a/example/bundle.js +++ b/example/bundle.js @@ -260,10 +260,10 @@ function(e,t,n){"use strict";e.exports=n(/*! ./lib/React */16)},/*!************* function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=n(/*! react */78),a=r(o),i=n(/*! react-dom */98),s=n(/*! ../src/react-stars */80),u=r(s),l={size:30,value:2.5,edit:!1},c={size:50,count:10,char:"",color1:"#ff9900",color2:"#6599ff",onChange:function(e){console.log("Example 2: new value is "+e)}},p={size:40,count:7,half:!1,value:4,onChange:function(e){console.log("Example 3: new value is "+e)}};(0,i.render)(a.default.createElement("div",null,a.default.createElement("h1",null,"react-stars examples"),a.default.createElement("p",null,a.default.createElement("i",null,"Star rating component for your React projects")),"Custom size, preset value, not editable",a.default.createElement(u.default,l),"Custom character, custom colors, 10 stars",a.default.createElement(u.default,c),"Editable, preset value, half stars off",a.default.createElement(u.default,p),a.default.createElement("a",{href:"https://github.com/n49/react-stars"},"Github")," | ",a.default.createElement("a",{href:"https://www.npmjs.com/package/react-stars"},"NPM package")),document.getElementById("root"))},/*!****************************!*\ !*** ./src/react-stars.js ***! \****************************/ -function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;tt/2}},{key:"mouseLeave",value:function(){var e=this.state,t=e.value,n=e.halfStar,r=e.config;r.edit&&(r.half&&(n.hidden=!this.isDecimal(t),n.at=Math.floor(this.state.value)),this.setState({stars:this.getStars()}))}},{key:"clicked",value:function(e){var t=this.state,n=t.config,r=t.halfStar;if(n.edit){var o=Number(e.target.getAttribute("data-index")),a=void 0;if(n.half){var i=this.moreThanHalf(e,n.size);r.hidden=i,i&&(o+=1),a=i?o:o+.5,r.at=o}else a=o+=1;this.setState({value:a,stars:this.getStars(o)}),this.props.onChange(a)}}},{key:"renderHalfStarStyleElement",value:function(){var e=this.state,t=e.config,n=e.uniqueness;return c.default.createElement("style",{dangerouslySetInnerHTML:{__html:v(t.color2,n)}})}},{key:"renderStars",value:function(){var e=this,t=this.state,n=t.halfStar,r=t.stars,o=t.uniqueness,a=t.config,i=a.color1,u=a.color2,l=a.size,p=a.char,d=a.half,f=a.edit;return r.map(function(t,r){var a="";d&&!n.hidden&&n.at===r&&(a="react-stars-"+o);var v=s({},h,{color:t.active?u:i,cursor:f?"pointer":"default",fontSize:l+"px"});return c.default.createElement("span",{className:a,style:v,key:r,"data-index":r,"data-forhalf":p,onMouseOver:e.mouseOver.bind(e),onMouseMove:e.mouseOver.bind(e),onMouseLeave:e.mouseLeave.bind(e),onClick:e.clicked.bind(e)},p)})}},{key:"render",value:function(){var e=this.props.className;return c.default.createElement("div",{className:e,style:f},this.state.config.half?this.renderHalfStarStyleElement():"",this.renderStars())}}]),t}(l.Component);m.propTypes={className:d.default.string,edit:d.default.bool,half:d.default.bool,value:d.default.number,count:d.default.number,char:d.default.string,size:d.default.number,color1:d.default.string,color2:d.default.string},t.default=m},/*!*****************************************!*\ +function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;tt/2}},{key:"mouseLeave",value:function(){var e=this.state,t=e.value,n=e.halfStar,r=e.config;r.edit&&(r.half&&(n.hidden=!this.isDecimal(t),n.at=Math.floor(this.state.value)),this.setState({stars:this.getStars()}))}},{key:"clicked",value:function(e){var t=this.state,n=t.config,r=t.halfStar;if(n.edit){var o=Number(e.target.getAttribute("data-index")),a=void 0;if(n.half){var i=this.moreThanHalf(e,n.size);r.hidden=i,i&&(o+=1),a=i?o:o+.5,r.at=o}else a=o+=1;this.setState({value:a,stars:this.getStars(o)}),this.props.onChange(a)}}},{key:"renderHalfStarStyleElement",value:function(){var e=this.state,t=e.config,n=e.uniqueness;return c.default.createElement("style",{dangerouslySetInnerHTML:{__html:v(t.color2,n)}})}},{key:"renderStars",value:function(){var e=this,t=this.state,n=t.halfStar,r=t.stars,o=t.uniqueness,a=t.config,i=a.color1,u=a.color2,l=a.size,p=a.char,d=a.half,f=a.edit;return r.map(function(t,r){var a="";d&&!n.hidden&&n.at===r&&(a="react-stars-"+o);var v=s({},h,{color:t.active?u:i,cursor:f?"pointer":"default",fontSize:l+"px"});return c.default.createElement("span",{className:a,style:v,key:r,"data-index":r,"data-forhalf":p,onMouseOver:e.mouseOver.bind(e),onMouseMove:e.mouseOver.bind(e),onMouseLeave:e.mouseLeave.bind(e),onClick:e.clicked.bind(e)},p)})}},{key:"render",value:function(){var e=this.props.className;return c.default.createElement("div",{className:e,style:f},this.state.config.half?this.renderHalfStarStyleElement():"",this.renderStars())}}]),t}(l.Component);m.propTypes={className:d.default.string,edit:d.default.bool,half:d.default.bool,value:d.default.number,count:d.default.number,char:d.default.string,size:d.default.number,color1:d.default.string,color2:d.default.string},t.default=m},/*!*****************************************!*\ !*** ./~/create-react-class/factory.js ***! \*****************************************/ -function(e,t,n){"use strict";function r(e){return e}function o(e,t,n){function o(e,t){var n=y.hasOwnProperty(t)?y[t]:null;E.hasOwnProperty(t)&&u("OVERRIDE_BASE"===n,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",t),e&&u("DEFINE_MANY"===n||"DEFINE_MANY_MERGED"===n,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",t)}function a(e,n){if(n){u("function"!=typeof n,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),u(!t(n),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var r=e.prototype,a=r.__reactAutoBindPairs;n.hasOwnProperty(l)&&_.mixins(e,n.mixins);for(var i in n)if(n.hasOwnProperty(i)&&i!==l){var s=n[i],c=r.hasOwnProperty(i);if(o(c,i),_.hasOwnProperty(i))_[i](e,s);else{var p=y.hasOwnProperty(i),h="function"==typeof s,v=h&&!p&&!c&&n.autobind!==!1;if(v)a.push(i,s),r[i]=s;else if(c){var m=y[i];u(p&&("DEFINE_MANY_MERGED"===m||"DEFINE_MANY"===m),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",m,i),"DEFINE_MANY_MERGED"===m?r[i]=d(r[i],s):"DEFINE_MANY"===m&&(r[i]=f(r[i],s))}else r[i]=s}}}}function c(e,t){if(t)for(var n in t){var r=t[n];if(t.hasOwnProperty(n)){var o=n in _;u(!o,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',n);var a=n in e;u(!a,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",n),e[n]=r}}}function p(e,t){u(e&&t&&"object"==typeof e&&"object"==typeof t,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var n in t)t.hasOwnProperty(n)&&(u(void 0===e[n],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",n),e[n]=t[n]);return e}function d(e,t){return function(){var n=e.apply(this,arguments),r=t.apply(this,arguments);if(null==n)return r;if(null==r)return n;var o={};return p(o,n),p(o,r),o}}function f(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function h(e,t){var n=t.bind(e);return n}function v(e){for(var t=e.__reactAutoBindPairs,n=0;n