diff --git a/lib/ReactCardFlip.js b/lib/ReactCardFlip.js index 444f1fa..1563311 100644 --- a/lib/ReactCardFlip.js +++ b/lib/ReactCardFlip.js @@ -37,15 +37,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); var React = __importStar(require("react")); var react_1 = require("react"); var ReactCardFlip = function (props) { - var _a = props.cardStyles, back = _a.back, front = _a.front, cardZIndex = props.cardZIndex, containerStyle = props.containerStyle, containerClassName = props.containerClassName, flipDirection = props.flipDirection, flipSpeedFrontToBack = props.flipSpeedFrontToBack, flipSpeedBackToFront = props.flipSpeedBackToFront, infinite = props.infinite; - var _b = (0, react_1.useState)(props.isFlipped), isFlipped = _b[0], setFlipped = _b[1]; - var _c = (0, react_1.useState)(0), rotation = _c[0], setRotation = _c[1]; + var _a = __assign({ cardStyles: { + back: {}, + front: {}, + }, cardZIndex: 'auto', containerStyle: {}, flipDirection: 'horizontal', flipSpeedBackToFront: 0.6, flipSpeedFrontToBack: 0.6, infinite: false, isFlipped: false }, props), _b = _a.cardStyles, back = _b.back, front = _b.front, cardZIndex = _a.cardZIndex, containerStyle = _a.containerStyle, containerClassName = _a.containerClassName, flipDirection = _a.flipDirection, flipSpeedFrontToBack = _a.flipSpeedFrontToBack, flipSpeedBackToFront = _a.flipSpeedBackToFront, infinite = _a.infinite, isFlipped = _a.isFlipped; + var _c = (0, react_1.useState)(isFlipped), isFlippedState = _c[0], setFlipped = _c[1]; + var _d = (0, react_1.useState)(0), rotation = _d[0], setRotation = _d[1]; (0, react_1.useEffect)(function () { - if (props.isFlipped !== isFlipped) { - setFlipped(props.isFlipped); + if (isFlipped !== isFlippedState) { + setFlipped(isFlipped); setRotation(function (c) { return c + 180; }); } - }, [props.isFlipped]); + }, [isFlipped]); var getContainerClassName = (0, react_1.useMemo)(function () { var className = 'react-card-flip'; if (containerClassName) { @@ -81,17 +84,4 @@ var ReactCardFlip = function (props) { React.createElement("div", { className: "react-card-front", style: styles.front }, getComponent(0)), React.createElement("div", { className: "react-card-back", style: styles.back }, getComponent(1))))); }; -ReactCardFlip.defaultProps = { - cardStyles: { - back: {}, - front: {}, - }, - cardZIndex: 'auto', - containerStyle: {}, - flipDirection: 'horizontal', - flipSpeedBackToFront: 0.6, - flipSpeedFrontToBack: 0.6, - infinite: false, - isFlipped: false, -}; exports.default = ReactCardFlip; diff --git a/package.json b/package.json index 5742daf..04b2383 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-card-flip", - "version": "1.2.1", + "version": "1.2.2", "description": "ReactCardFlip", "main": "./lib/ReactCardFlip.js", "types": "./lib/ReactCardFlip.d.ts",