@paypal/react-paypal-js
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -13,2 +13,6 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -22,6 +26,6 @@ | ||
import React, { useContext, useReducer, useEffect, createContext, useRef } from 'react'; | ||
import React, { useContext, useReducer, useEffect, createContext, useRef, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
/*! | ||
* paypal-js v1.0.2 (2020-09-30T18:10:04.928Z) | ||
* paypal-js v1.0.3 (2020-10-14T17:44:15.504Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -440,2 +444,7 @@ * | ||
var SCRIPT_LOADING_STATE = { | ||
PENDING: "pending", | ||
REJECTED: "rejected", | ||
RESOLVED: "resolved" | ||
}; | ||
var ScriptContext = /*#__PURE__*/createContext(); | ||
@@ -446,6 +455,6 @@ var ScriptDispatchContext = /*#__PURE__*/createContext(); | ||
switch (action.type) { | ||
case "setIsLoaded": | ||
case "setLoadingStatus": | ||
return { | ||
options: _objectSpread({}, state.options), | ||
isLoaded: action.value | ||
loadingStatus: action.value | ||
}; | ||
@@ -455,14 +464,6 @@ | ||
return { | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING, | ||
options: action.value | ||
}; | ||
// deprecated - remove for the v2 release | ||
case "changeCurrency": | ||
return { | ||
options: _objectSpread(_objectSpread({}, state.options), {}, { | ||
currency: action.value | ||
}), | ||
isLoaded: false | ||
}; | ||
default: | ||
@@ -483,3 +484,12 @@ { | ||
return [scriptContext, dispatchContext]; | ||
var loadingStatus = scriptContext.loadingStatus, | ||
restScriptContext = _objectWithoutProperties(scriptContext, ["loadingStatus"]); | ||
var derivedStatusContext = _objectSpread(_objectSpread({}, restScriptContext), {}, { | ||
isPending: loadingStatus === SCRIPT_LOADING_STATE.PENDING, | ||
isResolved: loadingStatus === SCRIPT_LOADING_STATE.RESOLVED, | ||
isRejected: loadingStatus === SCRIPT_LOADING_STATE.REJECTED | ||
}); | ||
return [derivedStatusContext, dispatchContext]; | ||
} | ||
@@ -492,3 +502,3 @@ | ||
options: options, | ||
isLoaded: false | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING | ||
}; | ||
@@ -502,3 +512,3 @@ | ||
useEffect(function () { | ||
if (state.isLoaded) return; | ||
if (state.loadingStatus !== SCRIPT_LOADING_STATE.PENDING) return; | ||
var isSubscribed = true; | ||
@@ -508,6 +518,13 @@ loadScript(state.options).then(function () { | ||
dispatch({ | ||
type: "setIsLoaded", | ||
value: true | ||
type: "setLoadingStatus", | ||
value: SCRIPT_LOADING_STATE.RESOLVED | ||
}); | ||
} | ||
})["catch"](function () { | ||
if (isSubscribed) { | ||
dispatch({ | ||
type: "setLoadingStatus", | ||
value: SCRIPT_LOADING_STATE.REJECTED | ||
}); | ||
} | ||
}); | ||
@@ -533,2 +550,3 @@ return function () { | ||
currency: PropTypes.string, | ||
"data-client-token": PropTypes.string, | ||
"data-csp-nonce": PropTypes.string, | ||
@@ -562,3 +580,3 @@ "data-order-id": PropTypes.string, | ||
_usePayPalScriptReduc3 = _usePayPalScriptReduc2[0], | ||
isLoaded = _usePayPalScriptReduc3.isLoaded, | ||
isResolved = _usePayPalScriptReduc3.isResolved, | ||
options = _usePayPalScriptReduc3.options; | ||
@@ -568,27 +586,32 @@ | ||
var buttons = useRef(null); | ||
useEffect(function () { | ||
if (isLoaded) { | ||
verifyGlobalStateForButtons(options); | ||
buttons.current = window.paypal.Buttons(_objectSpread({}, props)); | ||
if (!buttons.current.isEligible()) { | ||
return; | ||
} | ||
var _useState = useState(null), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
setErrorState = _useState2[1]; | ||
buttons.current.render(buttonsContainerRef.current)["catch"](function (err) { | ||
console.error("Failed to render <PayPalButtons /> component. ".concat(err)); | ||
}); | ||
} else { | ||
// close the buttons when the script is reloaded | ||
useEffect(function () { | ||
var cleanup = function cleanup() { | ||
if (buttons.current) { | ||
buttons.current.close(); | ||
} | ||
}; | ||
if (!isResolved) { | ||
return cleanup; | ||
} | ||
return function () { | ||
// close the buttons when the component unmounts | ||
if (buttons.current) { | ||
buttons.current.close(); | ||
} | ||
}; | ||
if (!hasValidGlobalStateForButtons(options, setErrorState)) { | ||
return cleanup; | ||
} | ||
buttons.current = window.paypal.Buttons(_objectSpread({}, props)); | ||
if (!buttons.current.isEligible()) { | ||
return cleanup; | ||
} | ||
buttons.current.render(buttonsContainerRef.current)["catch"](function (err) { | ||
console.error("Failed to render <PayPalButtons /> component. ".concat(err)); | ||
}); | ||
return cleanup; | ||
}); | ||
@@ -600,3 +623,3 @@ return /*#__PURE__*/React.createElement("div", { | ||
function verifyGlobalStateForButtons(_ref3) { | ||
function hasValidGlobalStateForButtons(_ref3, setErrorState) { | ||
var _ref3$components = _ref3.components, | ||
@@ -606,3 +629,3 @@ components = _ref3$components === void 0 ? "" : _ref3$components; | ||
if (typeof window.paypal.Buttons !== "undefined") { | ||
return; | ||
return true; | ||
} | ||
@@ -618,3 +641,6 @@ | ||
throw new Error(errorMessage); | ||
setErrorState(function () { | ||
throw new Error(errorMessage); | ||
}); | ||
return false; | ||
} | ||
@@ -728,3 +754,3 @@ | ||
_usePayPalScriptReduc6 = _usePayPalScriptReduc5[0], | ||
isLoaded = _usePayPalScriptReduc6.isLoaded, | ||
isResolved = _usePayPalScriptReduc6.isResolved, | ||
options = _usePayPalScriptReduc6.options; | ||
@@ -734,15 +760,25 @@ | ||
var mark = useRef(null); | ||
var _useState3 = useState(null), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
setErrorState = _useState4[1]; | ||
useEffect(function () { | ||
if (isLoaded && !mark.current) { | ||
verifyGlobalStateForMarks(options); | ||
mark.current = window.paypal.Marks(_objectSpread({}, props)); | ||
if (!isResolved || mark.current) { | ||
return; | ||
} | ||
if (!mark.current.isEligible()) { | ||
return; | ||
} | ||
if (!hasValidStateForMarks(options, setErrorState)) { | ||
return; | ||
} | ||
mark.current.render(markContainerRef.current)["catch"](function (err) { | ||
console.error("Failed to render <PayPalMarks /> component. ".concat(err)); | ||
}); | ||
mark.current = window.paypal.Marks(_objectSpread({}, props)); | ||
if (!mark.current.isEligible()) { | ||
return; | ||
} | ||
mark.current.render(markContainerRef.current)["catch"](function (err) { | ||
console.error("Failed to render <PayPalMarks /> component. ".concat(err)); | ||
}); | ||
}); | ||
@@ -754,3 +790,3 @@ return /*#__PURE__*/React.createElement("div", { | ||
function verifyGlobalStateForMarks(_ref4) { | ||
function hasValidStateForMarks(_ref4, setErrorState) { | ||
var _ref4$components = _ref4.components, | ||
@@ -760,3 +796,3 @@ components = _ref4$components === void 0 ? "" : _ref4$components; | ||
if (typeof window.paypal.Marks !== "undefined") { | ||
return; | ||
return true; | ||
} | ||
@@ -771,3 +807,6 @@ | ||
throw new Error(errorMessage); | ||
setErrorState(function () { | ||
throw new Error(errorMessage); | ||
}); | ||
return false; | ||
} | ||
@@ -786,3 +825,3 @@ | ||
_usePayPalScriptReduc8 = _slicedToArray(_usePayPalScriptReduc7, 1), | ||
isLoaded = _usePayPalScriptReduc8[0].isLoaded; | ||
isResolved = _usePayPalScriptReduc8[0].isResolved; | ||
@@ -792,8 +831,10 @@ var messagesContainerRef = useRef(null); | ||
useEffect(function () { | ||
if (isLoaded) { | ||
messages.current = window.paypal.Messages(_objectSpread({}, props)); | ||
messages.current.render(messagesContainerRef.current)["catch"](function (err) { | ||
console.error("Failed to render <PayPalMessages /> component. ".concat(err)); | ||
}); | ||
if (!isResolved) { | ||
return; | ||
} | ||
messages.current = window.paypal.Messages(_objectSpread({}, props)); | ||
messages.current.render(messagesContainerRef.current)["catch"](function (err) { | ||
console.error("Failed to render <PayPalMessages /> component. ".concat(err)); | ||
}); | ||
}); | ||
@@ -800,0 +841,0 @@ return /*#__PURE__*/React.createElement("div", { |
@@ -5,10 +5,12 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
var PropTypes = require('prop-types'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); | ||
/*! | ||
* paypal-js v1.0.2 (2020-09-30T18:10:04.928Z) | ||
* paypal-js v1.0.3 (2020-10-14T17:44:15.504Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -425,2 +427,7 @@ * | ||
const SCRIPT_LOADING_STATE = { | ||
PENDING: "pending", | ||
REJECTED: "rejected", | ||
RESOLVED: "resolved" | ||
}; | ||
const ScriptContext = /*#__PURE__*/React.createContext(); | ||
@@ -431,7 +438,7 @@ const ScriptDispatchContext = /*#__PURE__*/React.createContext(); | ||
switch (action.type) { | ||
case "setIsLoaded": | ||
case "setLoadingStatus": | ||
return { | ||
options: { ...state.options | ||
}, | ||
isLoaded: action.value | ||
loadingStatus: action.value | ||
}; | ||
@@ -441,14 +448,6 @@ | ||
return { | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING, | ||
options: action.value | ||
}; | ||
// deprecated - remove for the v2 release | ||
case "changeCurrency": | ||
return { | ||
options: { ...state.options, | ||
currency: action.value | ||
}, | ||
isLoaded: false | ||
}; | ||
default: | ||
@@ -469,3 +468,12 @@ { | ||
return [scriptContext, dispatchContext]; | ||
const { | ||
loadingStatus, | ||
...restScriptContext | ||
} = scriptContext; | ||
const derivedStatusContext = { ...restScriptContext, | ||
isPending: loadingStatus === SCRIPT_LOADING_STATE.PENDING, | ||
isResolved: loadingStatus === SCRIPT_LOADING_STATE.RESOLVED, | ||
isRejected: loadingStatus === SCRIPT_LOADING_STATE.REJECTED | ||
}; | ||
return [derivedStatusContext, dispatchContext]; | ||
} | ||
@@ -479,7 +487,7 @@ | ||
options, | ||
isLoaded: false | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING | ||
}; | ||
const [state, dispatch] = React.useReducer(scriptReducer, initialState); | ||
React.useEffect(() => { | ||
if (state.isLoaded) return; | ||
if (state.loadingStatus !== SCRIPT_LOADING_STATE.PENDING) return; | ||
let isSubscribed = true; | ||
@@ -489,6 +497,13 @@ loadScript(state.options).then(() => { | ||
dispatch({ | ||
type: "setIsLoaded", | ||
value: true | ||
type: "setLoadingStatus", | ||
value: SCRIPT_LOADING_STATE.RESOLVED | ||
}); | ||
} | ||
}).catch(() => { | ||
if (isSubscribed) { | ||
dispatch({ | ||
type: "setLoadingStatus", | ||
value: SCRIPT_LOADING_STATE.REJECTED | ||
}); | ||
} | ||
}); | ||
@@ -499,5 +514,5 @@ return () => { | ||
}); | ||
return /*#__PURE__*/React__default.createElement(ScriptContext.Provider, { | ||
return /*#__PURE__*/React__default['default'].createElement(ScriptContext.Provider, { | ||
value: state | ||
}, /*#__PURE__*/React__default.createElement(ScriptDispatchContext.Provider, { | ||
}, /*#__PURE__*/React__default['default'].createElement(ScriptDispatchContext.Provider, { | ||
value: dispatch | ||
@@ -508,20 +523,21 @@ }, children)); | ||
PayPalScriptProvider.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
options: PropTypes.exact({ | ||
"buyer-country": PropTypes.string, | ||
"client-id": PropTypes.string.isRequired, | ||
commit: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), | ||
components: PropTypes.string, | ||
currency: PropTypes.string, | ||
"data-csp-nonce": PropTypes.string, | ||
"data-order-id": PropTypes.string, | ||
"data-page-type": PropTypes.string, | ||
"data-partner-attribution-id": PropTypes.string, | ||
debug: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), | ||
"disable-funding": PropTypes.string, | ||
"integration-date": PropTypes.string, | ||
intent: PropTypes.string, | ||
locale: PropTypes.string, | ||
"merchant-id": PropTypes.string, | ||
vault: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]) | ||
children: PropTypes__default['default'].node.isRequired, | ||
options: PropTypes__default['default'].exact({ | ||
"buyer-country": PropTypes__default['default'].string, | ||
"client-id": PropTypes__default['default'].string.isRequired, | ||
commit: PropTypes__default['default'].oneOfType([PropTypes__default['default'].bool, PropTypes__default['default'].string]), | ||
components: PropTypes__default['default'].string, | ||
currency: PropTypes__default['default'].string, | ||
"data-client-token": PropTypes__default['default'].string, | ||
"data-csp-nonce": PropTypes__default['default'].string, | ||
"data-order-id": PropTypes__default['default'].string, | ||
"data-page-type": PropTypes__default['default'].string, | ||
"data-partner-attribution-id": PropTypes__default['default'].string, | ||
debug: PropTypes__default['default'].oneOfType([PropTypes__default['default'].bool, PropTypes__default['default'].string]), | ||
"disable-funding": PropTypes__default['default'].string, | ||
"integration-date": PropTypes__default['default'].string, | ||
intent: PropTypes__default['default'].string, | ||
locale: PropTypes__default['default'].string, | ||
"merchant-id": PropTypes__default['default'].string, | ||
vault: PropTypes__default['default'].oneOfType([PropTypes__default['default'].bool, PropTypes__default['default'].string]) | ||
}) | ||
@@ -543,3 +559,3 @@ }; | ||
const [{ | ||
isLoaded, | ||
isResolved, | ||
options | ||
@@ -549,30 +565,31 @@ }] = usePayPalScriptReducer(); | ||
const buttons = React.useRef(null); | ||
const [, setErrorState] = React.useState(null); | ||
React.useEffect(() => { | ||
if (isLoaded) { | ||
verifyGlobalStateForButtons(options); | ||
buttons.current = window.paypal.Buttons({ ...props | ||
}); | ||
if (!buttons.current.isEligible()) { | ||
return; | ||
} | ||
buttons.current.render(buttonsContainerRef.current).catch(err => { | ||
console.error(`Failed to render <PayPalButtons /> component. ${err}`); | ||
}); | ||
} else { | ||
// close the buttons when the script is reloaded | ||
const cleanup = () => { | ||
if (buttons.current) { | ||
buttons.current.close(); | ||
} | ||
}; | ||
if (!isResolved) { | ||
return cleanup; | ||
} | ||
return () => { | ||
// close the buttons when the component unmounts | ||
if (buttons.current) { | ||
buttons.current.close(); | ||
} | ||
}; | ||
if (!hasValidGlobalStateForButtons(options, setErrorState)) { | ||
return cleanup; | ||
} | ||
buttons.current = window.paypal.Buttons({ ...props | ||
}); | ||
if (!buttons.current.isEligible()) { | ||
return cleanup; | ||
} | ||
buttons.current.render(buttonsContainerRef.current).catch(err => { | ||
console.error(`Failed to render <PayPalButtons /> component. ${err}`); | ||
}); | ||
return cleanup; | ||
}); | ||
return /*#__PURE__*/React__default.createElement("div", { | ||
return /*#__PURE__*/React__default['default'].createElement("div", { | ||
ref: buttonsContainerRef | ||
@@ -582,7 +599,7 @@ }); | ||
function verifyGlobalStateForButtons({ | ||
function hasValidGlobalStateForButtons({ | ||
components = "" | ||
}) { | ||
}, setErrorState) { | ||
if (typeof window.paypal.Buttons !== "undefined") { | ||
return; | ||
return true; | ||
} | ||
@@ -598,3 +615,6 @@ | ||
throw new Error(errorMessage); | ||
setErrorState(() => { | ||
throw new Error(errorMessage); | ||
}); | ||
return false; | ||
} | ||
@@ -606,3 +626,3 @@ | ||
*/ | ||
createOrder: PropTypes.func, | ||
createOrder: PropTypes__default['default'].func, | ||
@@ -612,3 +632,3 @@ /** | ||
*/ | ||
createBillingAgreement: PropTypes.func, | ||
createBillingAgreement: PropTypes__default['default'].func, | ||
@@ -618,3 +638,3 @@ /** | ||
*/ | ||
createSubscription: PropTypes.func, | ||
createSubscription: PropTypes__default['default'].func, | ||
@@ -625,3 +645,3 @@ /** | ||
*/ | ||
fundingSource: PropTypes.string, | ||
fundingSource: PropTypes__default['default'].string, | ||
@@ -631,9 +651,9 @@ /** | ||
*/ | ||
style: PropTypes.exact({ | ||
color: PropTypes.string, | ||
height: PropTypes.number, | ||
label: PropTypes.string, | ||
layout: PropTypes.string, | ||
shape: PropTypes.string, | ||
tagline: PropTypes.bool | ||
style: PropTypes__default['default'].exact({ | ||
color: PropTypes__default['default'].string, | ||
height: PropTypes__default['default'].number, | ||
label: PropTypes__default['default'].string, | ||
layout: PropTypes__default['default'].string, | ||
shape: PropTypes__default['default'].string, | ||
tagline: PropTypes__default['default'].bool | ||
}), | ||
@@ -648,3 +668,3 @@ | ||
*/ | ||
shippingPreference: PropTypes.oneOf(["GET_FROM_FILE", "NO_SHIPPING", "SET_PROVIDED_ADDRESS"]), | ||
shippingPreference: PropTypes__default['default'].oneOf(["GET_FROM_FILE", "NO_SHIPPING", "SET_PROVIDED_ADDRESS"]), | ||
@@ -654,3 +674,3 @@ /** | ||
*/ | ||
onApprove: PropTypes.func, | ||
onApprove: PropTypes__default['default'].func, | ||
@@ -661,3 +681,3 @@ /** | ||
*/ | ||
onCancel: PropTypes.func, | ||
onCancel: PropTypes__default['default'].func, | ||
@@ -667,3 +687,3 @@ /** | ||
*/ | ||
onClick: PropTypes.func, | ||
onClick: PropTypes__default['default'].func, | ||
@@ -674,3 +694,3 @@ /** | ||
*/ | ||
onError: PropTypes.func, | ||
onError: PropTypes__default['default'].func, | ||
@@ -680,3 +700,3 @@ /** | ||
*/ | ||
onInit: PropTypes.func, | ||
onInit: PropTypes__default['default'].func, | ||
@@ -686,3 +706,3 @@ /** | ||
*/ | ||
onShippingChange: PropTypes.func | ||
onShippingChange: PropTypes__default['default'].func | ||
}; | ||
@@ -719,3 +739,3 @@ PayPalButtons.defaultProps = { | ||
const [{ | ||
isLoaded, | ||
isResolved, | ||
options | ||
@@ -725,18 +745,24 @@ }] = usePayPalScriptReducer(); | ||
const mark = React.useRef(null); | ||
const [, setErrorState] = React.useState(null); | ||
React.useEffect(() => { | ||
if (isLoaded && !mark.current) { | ||
verifyGlobalStateForMarks(options); | ||
mark.current = window.paypal.Marks({ ...props | ||
}); | ||
if (!isResolved || mark.current) { | ||
return; | ||
} | ||
if (!mark.current.isEligible()) { | ||
return; | ||
} | ||
if (!hasValidStateForMarks(options, setErrorState)) { | ||
return; | ||
} | ||
mark.current.render(markContainerRef.current).catch(err => { | ||
console.error(`Failed to render <PayPalMarks /> component. ${err}`); | ||
}); | ||
mark.current = window.paypal.Marks({ ...props | ||
}); | ||
if (!mark.current.isEligible()) { | ||
return; | ||
} | ||
mark.current.render(markContainerRef.current).catch(err => { | ||
console.error(`Failed to render <PayPalMarks /> component. ${err}`); | ||
}); | ||
}); | ||
return /*#__PURE__*/React__default.createElement("div", { | ||
return /*#__PURE__*/React__default['default'].createElement("div", { | ||
ref: markContainerRef | ||
@@ -746,7 +772,7 @@ }); | ||
function verifyGlobalStateForMarks({ | ||
function hasValidStateForMarks({ | ||
components = "" | ||
}) { | ||
}, setErrorState) { | ||
if (typeof window.paypal.Marks !== "undefined") { | ||
return; | ||
return true; | ||
} | ||
@@ -761,3 +787,6 @@ | ||
throw new Error(errorMessage); | ||
setErrorState(() => { | ||
throw new Error(errorMessage); | ||
}); | ||
return false; | ||
} | ||
@@ -770,3 +799,3 @@ | ||
*/ | ||
fundingSource: PropTypes.string | ||
fundingSource: PropTypes__default['default'].string | ||
}; | ||
@@ -776,3 +805,3 @@ | ||
const [{ | ||
isLoaded | ||
isResolved | ||
}] = usePayPalScriptReducer(); | ||
@@ -782,11 +811,13 @@ const messagesContainerRef = React.useRef(null); | ||
React.useEffect(() => { | ||
if (isLoaded) { | ||
messages.current = window.paypal.Messages({ ...props | ||
}); | ||
messages.current.render(messagesContainerRef.current).catch(err => { | ||
console.error(`Failed to render <PayPalMessages /> component. ${err}`); | ||
}); | ||
if (!isResolved) { | ||
return; | ||
} | ||
messages.current = window.paypal.Messages({ ...props | ||
}); | ||
messages.current.render(messagesContainerRef.current).catch(err => { | ||
console.error(`Failed to render <PayPalMessages /> component. ${err}`); | ||
}); | ||
}); | ||
return /*#__PURE__*/React__default.createElement("div", { | ||
return /*#__PURE__*/React__default['default'].createElement("div", { | ||
ref: messagesContainerRef | ||
@@ -793,0 +824,0 @@ }); |
{ | ||
"name": "@paypal/react-paypal-js", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "React components for the PayPal JS SDK", | ||
@@ -10,3 +10,5 @@ "keywords": [ | ||
"checkout", | ||
"payment" | ||
"payment", | ||
"payment buttons", | ||
"paypal javascript sdk" | ||
], | ||
@@ -20,2 +22,3 @@ "main": "dist/react-paypal.node.js", | ||
"test": "jest", | ||
"start": "npm run storybook", | ||
"storybook": "start-storybook -p 6006", | ||
@@ -38,3 +41,3 @@ "build-storybook": "build-storybook", | ||
"dependencies": { | ||
"@paypal/paypal-js": "^1.0.3", | ||
"@paypal/paypal-js": "^1.0.4", | ||
"@paypal/sdk-constants": "^1.0.75", | ||
@@ -44,33 +47,33 @@ "prop-types": "^15.7.2" | ||
"devDependencies": { | ||
"@babel/core": "^7.10.4", | ||
"@babel/preset-env": "^7.10.4", | ||
"@babel/preset-react": "^7.10.4", | ||
"@rollup/plugin-babel": "^5.0.4", | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"@rollup/plugin-replace": "^2.3.3", | ||
"@storybook/addon-actions": "^6.0.16", | ||
"@storybook/addon-essentials": "^6.0.16", | ||
"@storybook/addon-links": "^6.0.16", | ||
"@storybook/react": "^6.0.16", | ||
"@babel/core": "^7.12.3", | ||
"@babel/preset-env": "^7.12.1", | ||
"@babel/preset-react": "^7.12.1", | ||
"@rollup/plugin-babel": "^5.2.1", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@rollup/plugin-replace": "^2.3.4", | ||
"@storybook/addon-actions": "^6.0.27", | ||
"@storybook/addon-essentials": "^6.0.27", | ||
"@storybook/addon-links": "^6.0.27", | ||
"@storybook/react": "^6.0.27", | ||
"@storybook/storybook-deployer": "^2.8.7", | ||
"@testing-library/react": "^10.4.7", | ||
"babel-jest": "^26.1.0", | ||
"@testing-library/react": "^11.1.0", | ||
"babel-jest": "^26.6.1", | ||
"babel-loader": "^8.1.0", | ||
"eslint": "^7.4.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-react": "^7.20.5", | ||
"eslint": "^7.12.1", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-react": "^7.21.5", | ||
"http-server": "^0.12.3", | ||
"husky": "^4.2.5", | ||
"jest": "^26.1.0", | ||
"lint-staged": "^10.2.11", | ||
"prettier": "^2.0.5", | ||
"husky": "^4.3.0", | ||
"jest": "^26.6.1", | ||
"lint-staged": "^10.5.0", | ||
"prettier": "^2.1.2", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"react-is": "^16.13.1", | ||
"rollup": "^2.21.0", | ||
"react-is": "^17.0.1", | ||
"rollup": "^2.32.1", | ||
"shelljs": "^0.8.4" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.3.0", | ||
"react-dom": "^16.3.0" | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1" | ||
}, | ||
@@ -77,0 +80,0 @@ "husky": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71043
1423
+ Addedreact@17.0.2(transitive)
+ Addedreact-dom@17.0.2(transitive)
+ Addedscheduler@0.20.2(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-dom@16.14.0(transitive)
- Removedscheduler@0.19.1(transitive)
Updated@paypal/paypal-js@^1.0.4