I am working on a React application (frontend canister) with a Rust backend canister. Based on the tutorials, it seems that you can call a backend function by importing the declaration file in the frontend component and calling the function. I am doing something like this:
import { backend } from "../declarations/backend";
export Form() {
return (
<button
onClick={async () => {
await backend.update();
}}></button>
);
}
However, I am getting this error here: Canister ID undefined error. As I mentioned in this thread, when I comment out the declaration import and onClick function, I no longer receive the error and can navigate to my local application successfully.
What is the best way to call a backend function on a frontend canister? What am I doing wrong?