I try to use snipcart in a single product page (like here) with react.
With the code below a click on the button (class="snipcart-add-item") doesn't do anything. How do I have to import?
In my version "data-api-key" is my correct snipcart api key of course.
import 'bootstrap/dist/css/bootstrap.min.css';
import "./App.css"
import React from 'react';
function App() {
return (
<div className="App">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://cdn.snipcart.com/scripts/2.0/snipcart.js" id="snipcart" data-api-key="API_KEY"></script>
<link href="https://cdn.snipcart.com/themes/2.0/base/snipcart.min.css" type="text/css" rel="stylesheet" />
<button
class="snipcart-add-item"
data-item-id="2"
data-item-name="Bacon"
data-item-price="3.00"
data-item-weight="20"
data-item-url="http://myapp.com/products/bacon"
data-item-description="Some fresh bacon">
Buy bacon
</button>
</div>
);
}
export default App;
Go to public/index.html
and paste your scripts and link inside the head