I have read all the other answers, but it doesnt seem to really work for me. At first I thought it worked but then I noticed it didnt. What is the best way to retrieve the value of the last event that happened. Sample code:
import { React, useState, useEffect } from "react";
const [counter, setCounter] = useState();
dex.getPastEvents('NewDeadline', {
filter: {},
fromBlock: 'latest',
toBlock: 'latest'
}).then(function(events){
for(var k in events){
console.log(events[k].returnValues["_deadline"]);
}
});
Of curse I could iterate throught them and get the last value of all the logs. But this doesnt seem like good practice.