I'm building a application with React and TypeScript ... When I try to .innerHTML or innerText something I got this error:
Object is possibly 'null'. TS2531
I'm new with TypeScript and I don't know what I should do, I know it's something related with interface ... but I can't find a specific resolve.
If someone can solve my problem with my code it would be great.
Thanks in advance . I let my code below:
const Home: FC = () => {
const percentage = 91;
const startingMinutes = 25;
let time = startingMinutes * 60;
const countdownEl = document.getElementById("countdown");
const updateCountDown = () => {
const minutes = Math.floor(time / 60);
let seconds = time % 60;
countdownEl.innerHTML=`${minutes}: ${seconds}`;
time--;
};
const changeTimer = () => {
var timer = document.getElementById("countdown");
var time = document.getElementById("time");
// timer.innerText=time;
};