-
Notifications
You must be signed in to change notification settings - Fork 25
Closed
Description
Hi!
I'm trying to implement your lib in a React functional component.
However I'm getting a Cannot read property 'tokenize' of undefined
error when attempting to get the reference for the tokenize function.
Here's a summary of my code:
import React, { useEffect, useState } from 'react'
// Braintree
import { Braintree, HostedField } from 'react-braintree-fields'
const Checkout = ({ location }) => {
const [tokenize, setTokenizeFunc] = useState(null)
return (
<Braintree
className={isReady ? '' : 'disabled'}
authorization='sandbox_xxxxxxxxxxxxx'
onAuthorizationSuccess={onAuthorizationSuccess}
onDataCollectorInstanceReady={onDataCollectorInstanceReady}
onError={handleError}
onCardTypeChange={onCardTypeChange}
getTokenRef={ref => setTokenizeFunc(ref)}
styles={{
'input': {
'font-size': 'inherit',
},
':focus': {
'color': 'blue'
},
}}>
[...]
</Braintree>
)
}
I've also tried doing something like getTokenRef={ref => setTokenizeFunc.bind(Braintree, ref)}
but still no luck.
Is this implementation possible? Or should I just stick to class components in this scenario?
Thank you!
Metadata
Metadata
Assignees
Labels
No labels