Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 9f54438

Browse files
authored
Merge pull request #2 from ChristopheBougere/master
add elements prop to hook
2 parents a7abf81 + fb1550e commit 9f54438

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function PaymentForm() {
2626
}
2727

2828
function Form() {
29-
const stripe = useStripe()
29+
const { stripe, elements } = useStripe()
3030

3131
const [formState, setFormState] = useState({
3232
name: '',
@@ -37,6 +37,12 @@ function Form() {
3737
event.preventDefault()
3838

3939
const paymentMethod = {
40+
payment_method: {
41+
card: elements.getElement('card'),
42+
billing_details: {
43+
name: 'Jenny Rosen',
44+
},
45+
},
4046
payment_method_data: {
4147
billing_details: {
4248
name: formState.name,

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-stripe-hooks",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "React hooks for Stripe.js and Stripe Elements",
55
"main": "dist/index.js",
66
"module": "dist/index.es.js",

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const Context = createContext()
55

66
const useStripe = () => useContext(Context)
77

8-
const HookProvider = ({ children, stripe }) => (
9-
<Context.Provider value={stripe}>
8+
const HookProvider = ({ children, stripe, elements }) => (
9+
<Context.Provider value={{ stripe, elements }}>
1010
{children}
1111
</Context.Provider>
1212
)

0 commit comments

Comments
 (0)