У меня проблемы с набором текста для this.props.stripe
. Я не уверен, какой тип мне нужно поставить.
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-stripe-elements/index.d.ts#L44
@types/react-stripe-elements
установлено.
<StripeProvider apiKey="xxx">
<div className="example">
<h1>React Stripe Elements Example</h1>
<Elements>
<CheckoutForm />
</Elements>
</div>
</StripeProvider>
import React from 'react';
import {CardElement, injectStripe } from 'react-stripe-elements';
type CheckoutFormProps = {
stripe: StripeProps
}
class CheckoutForm extends React.Component<CheckoutFormProps, {}> {
submit = async (ev: React.SyntheticEvent) => {
// User clicked submit
let {token} = await this.props.stripe.createToken({name: "Name"});
console.log(token);
}
render() {
return (
<div className="checkout">
<p>Would you like to complete the purchase?</p>
<CardElement />
<button onClick={this.submit}>Purchase</button>
</div>
);
}
}
export default injectStripe(CheckoutForm);
Ошибка: Cannot find name 'StripeProps.
Я также пытался InjectedStripeProps
.