I am trying to use an Alpaca form within a React app:
import React, { useEffect, useRef } from "react";
import $ from "jquery";
import * as popper from "popper.js";
import * as bootstrap from "bootstrap";
import * as handlebars from "handlebars";
import alpaca from "alpaca";
var jp = require('jsonpath');
export default function Form() {
useEffect(() => {
$("#form").alpaca({
});
}, []);
return <>
<h2>Alpaca Form</h2>
<div id="form"/>
</>;
}
webpack compiles this but in the browser I see this message:
jquery__WEBPACK_IMPORTED_MODULE_1___default(...)(...).alpaca is not a function
While running "npm start", the browser error shows: ReferenceError: jQuery is not defined.
Alpaca requires handlebars.js so you need to import it before importing alpaca.js. Can you try it and tell if this works for you?