Currently I have a utils file which I used to abstract away object related code for example,
// object
const Item = moralis.Object.extend("Item", {
getTitle: function() {
return this.get("title").toString();
},
getPrice: function() {
return this.get("price").toString();
}
}
// helper function
const createNewItem = async (
title,
price,
) => {
const newItem = new Item();
newItem.set("title", title.toString());
newItem.set("price", parseFloat(price));
const item = await newItem.save();
return item;
};
const editItem = async (title, price) => {
const itemQuery = new moralis.Query(Item);
const existingItem = await itemQuery.get(blanked);
};
// snip
but i notice with react-moralis which uses hooks, I canβt abstract away reusable code like this into some other file since I can only use hooks with components.
Does the team have any advise to abstract code like this or does the team intend for the same code to be written for every component that uses it or does the team intend for a mixed usage or react-moralis and vanilla moralis.
Thank you and have a nice day.