react-braintree-fields
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -238,2 +238,6 @@ (function (global, factory) { | ||
var Context = /*#__PURE__*/React__default['default'].createContext({ | ||
braintreeApi: null | ||
}); | ||
class Braintree extends React__default['default'].Component { | ||
@@ -243,2 +247,5 @@ constructor(props) { | ||
this.api = new BraintreeClientApi(props); | ||
this.contextValue = { | ||
braintreeApi: this.api | ||
}; | ||
} | ||
@@ -266,8 +273,2 @@ | ||
getChildContext() { | ||
return { | ||
braintreeApi: this.api | ||
}; | ||
} | ||
render() { | ||
@@ -284,5 +285,7 @@ var { | ||
return /*#__PURE__*/React__default['default'].createElement(Tag, { | ||
return /*#__PURE__*/React__default['default'].createElement(Context.Provider, { | ||
value: this.contextValue | ||
}, /*#__PURE__*/React__default['default'].createElement(Tag, { | ||
className: className | ||
}, this.props.children); | ||
}, this.props.children)); | ||
} | ||
@@ -306,5 +309,2 @@ | ||
}; | ||
Braintree.childContextTypes = { | ||
braintreeApi: PropTypes__default['default'].instanceOf(BraintreeClientApi) | ||
}; | ||
@@ -375,5 +375,3 @@ class BraintreeHostedField extends React__default['default'].Component { | ||
}; | ||
BraintreeHostedField.contextTypes = { | ||
braintreeApi: PropTypes__default['default'].instanceOf(BraintreeClientApi) | ||
}; | ||
BraintreeHostedField.contextType = Context; | ||
@@ -380,0 +378,0 @@ exports.Braintree = Braintree; |
@@ -230,2 +230,6 @@ import React from 'react'; | ||
var Context = /*#__PURE__*/React.createContext({ | ||
braintreeApi: null | ||
}); | ||
class Braintree extends React.Component { | ||
@@ -235,2 +239,5 @@ constructor(props) { | ||
this.api = new BraintreeClientApi(props); | ||
this.contextValue = { | ||
braintreeApi: this.api | ||
}; | ||
} | ||
@@ -258,8 +265,2 @@ | ||
getChildContext() { | ||
return { | ||
braintreeApi: this.api | ||
}; | ||
} | ||
render() { | ||
@@ -276,5 +277,7 @@ var { | ||
return /*#__PURE__*/React.createElement(Tag, { | ||
return /*#__PURE__*/React.createElement(Context.Provider, { | ||
value: this.contextValue | ||
}, /*#__PURE__*/React.createElement(Tag, { | ||
className: className | ||
}, this.props.children); | ||
}, this.props.children)); | ||
} | ||
@@ -298,5 +301,2 @@ | ||
}; | ||
Braintree.childContextTypes = { | ||
braintreeApi: PropTypes.instanceOf(BraintreeClientApi) | ||
}; | ||
@@ -367,7 +367,5 @@ class BraintreeHostedField extends React.Component { | ||
}; | ||
BraintreeHostedField.contextTypes = { | ||
braintreeApi: PropTypes.instanceOf(BraintreeClientApi) | ||
}; | ||
BraintreeHostedField.contextType = Context; | ||
export { Braintree, BraintreeHostedField as HostedField }; | ||
//# sourceMappingURL=build.module.js.map |
{ | ||
"name": "react-braintree-fields", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "React component for braintree hosted fields", | ||
@@ -5,0 +5,0 @@ "browser": "dist/build.full.js", |
@@ -79,3 +79,3 @@ # React components to integrate Braintree hosted fields | ||
See [demo site](https://nathanstitt.github.io/react-braintree-fields/) for a working example. It renders [demo/demo-class.jsx](demo/demo-class.jsx) There's also a [functional version](demo/demo-functional.jsx) available that illustrates how to work around the issue of storing a function reference using setState that was discovered in [issue #20](https://github.com/nathanstitt/react-braintree-fields/issues/20) | ||
See [demo site](https://nathanstitt.github.io/react-braintree-fields/) for a working example. It renders [demo/demo-class.jsx](demo/demo-class.jsx) There is also a [functional version](demo/demo-functional.jsx) available that illustrates how to work around the issue of storing a function reference using setState that was discovered in [issue #20](https://github.com/nathanstitt/react-braintree-fields/issues/20) | ||
@@ -86,7 +86,7 @@ ## Braintree Component | ||
* authorization: Required, either a [tokenization key or a client token](https://developers.braintreepayments.com/guides/hosted-fields/setup-and-integration/) | ||
* onAuthorizationSuccess: Function that will be called after Braintree successfully initializes the form. | ||
* onAuthorizationSuccess: Function that is called after Braintree successfully initializes the form | ||
* styles: Object containing [valid field styles](https://braintree.github.io/braintree-web/3.11.1/module-braintree-web_hosted-fields.html#.create) | ||
* onError: Function that will be called if an Braintree error is encountered. | ||
* onError: Function that is called if an Braintree error is encountered. | ||
* getTokenRef: A function that will be called once Braintree the API is initialized. It will be called with a function that can be used to initiate tokenization. | ||
* The tokenization function will return a Promise which will be either resolved or rejected. If resolved, the promise payload will contain an object with the `nonce` and other data from Braintree. | ||
* The tokenization function will return a Promise which will be either resolved or rejected. If resolved, the promise payload will contain an object with the `nonce` and other data from Braintree. If rejected it will return the error notice from Braintree | ||
* onDataCollectorInstanceReady: A function that will be called with the results of `Braintree.dataCollector.create`. This can be used in conjunction with [Braintree's Advanced Fraud Tools](https://developers.braintreepayments.com/guides/advanced-fraud-tools/client-side/javascript/v3). | ||
@@ -93,0 +93,0 @@ |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Api from './api'; | ||
import { Context } from './context' | ||
export default class Braintree extends React.Component { | ||
@@ -24,9 +26,6 @@ | ||
static childContextTypes = { | ||
braintreeApi: PropTypes.instanceOf(Api), | ||
} | ||
constructor(props) { | ||
super(props); | ||
this.api = new Api(props); | ||
this.contextValue = { braintreeApi: this.api } | ||
} | ||
@@ -53,6 +52,2 @@ | ||
getChildContext() { | ||
return { braintreeApi: this.api }; | ||
} | ||
render() { | ||
@@ -62,6 +57,9 @@ const { className: providedClass, tagName: Tag } = this.props; | ||
if (providedClass) { className += ` ${providedClass}`; } | ||
return ( | ||
<Tag className={className}> | ||
{this.props.children} | ||
</Tag> | ||
<Context.Provider value={this.contextValue}> | ||
<Tag className={className}> | ||
{this.props.children} | ||
</Tag> | ||
</Context.Provider> | ||
); | ||
@@ -68,0 +66,0 @@ } |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Api from './api'; | ||
import { Context } from './context' | ||
@@ -23,5 +23,3 @@ export default class BraintreeHostedField extends React.Component { | ||
static contextTypes = { | ||
braintreeApi: PropTypes.instanceOf(Api), | ||
} | ||
static contextType = Context | ||
@@ -28,0 +26,0 @@ state = {} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
36
35157
3053751