Hi, I am using react-moralis and I am trying to fetch a query when I press a button. From the github, it only explain how to fetch data when the component mounts.
const { data, error, isLoading } = useMoralisQuery("GameScore");
Please teach me how to fetch a query when I press a button.
I am trying to create a function fetchData
that is called whenever I click the button, but I can’t put the useMoralisQuery inside the function.
const fetchData = () => {
const { data, isLoading } = useMoralisQuery("Messages", (query) =>
query.equalTo("roomId", roomId)
);
Error says
React Hook “useMoralisQuery” is called in function “fetchData” that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter.eslintreact-hooks/rules-of-hooks