Live queries rock so much!! YEAH! I love Moralis more and more! Thank you for providing this awesome tool!
For future readers trying to implement live queries with React using Functional Components, here is my working code:
useEffect(async () => {
fetchYourData();
let query = new Moralis.Query("Data");
let subscription = await query.subscribe();
subscription.on("create", fetchYourData);
subscription.on("update", fetchYourData);
subscription.on("delete", fetchYourData);
}, []);
This will subscribe to any create, update or delete event of the Data-Table. Yes, you can subscribe to multiple events. I know, it is freaking awesome right!
Place the subscription inside useEffect, make the function async (!), and pass your data-fetching function as a callback to the subscription => BOOOM! there you go! live reloading your sexy React UI. 