I'm implementing Stripe in my project and in the official docs, one of the snippets of code advised to include in the component is:
const options = {
clientSecret,
appearance
};
I'm not too familiar with such declarations. It almost looks like a dictionary but it doesn't consist of a key value pair. I've heard of a concept of tuple but looking at how those are declared, this doesn't seem to match.
Nevertheless, I used that code in my implementation and it worked... until I decoupled this code into a child component. Now I need to pass the clientSecret
value as a prop.
Hence, I run:
export default function myComponent(props) {
const apearance = ...
const options = {
props.clientSecret,
appearance
};
return(
<Elements options={options} ...>
</Elements>
)
}
However, now I get an error at time of compilation on props.clientSecret
(specifically the dot) where the error message says:
Unexpected token, expected ","
Why am I unable to create the options
variable from props value, whereas it's possible if not invoking props? Is there a way around it?