The value of my timeDifference variable is not getting set in the code below. What am I doing wrong? My theDiff variable does contain a value, but when I run my setTimeDifference call it doesn't not set timeDifference to that value.
const[timeDifference, setTimeDifference] = useState();
const getTimeDifference = (signInTime) => {
let now = Date().toLocaleString();
let timeIn = new Date(signInTime);
now = moment(now);
timeIn = moment(timeIn);
let theDiff = moment(now).diff(moment(timeIn), 'minutes');
setTimeDifference(theDiff);
}
useEffect(() => {
getTimeDifference(props.timein);
console.log(timeDifference);
}, []);