Can we use setinterval without hooks and state in React

last week interviewer asked me this question. i don’t have an idea about it .anyone know?

Sure, people were doing it all the time before there were hooks, you just start the timer in a lifecycle method like componentDidMount. You do need to store the timer in state somewhere if you want to cancel the timer, which you likely want to do when the component is unmounted.