Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using React Stripe in a React project. I can learn from their documentation that to use Element components and Stripe objects, I need to set Elements provider in the root file of React. And to use Elements provider I need to call loadStripe with the publishable key. I do not want to set this publishable key to a constant value or environment variable. I want to call loadStripe after getting the publishable key as data from the server. In this case, my question is ...

1. After loading the Elements provider in the root file and receiving the key from the server, can loadStripe be called through it?
2. If it is not possible to put it in the root file, then can it be implemented in the other file without the root file like in payment or checkout file?


What I have tried:

<Elements stripe={stripePromise}>
       <App />
     </Elements>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900