I am trying to clone array to functional state using following code. But after setting state to new array i am still getting null array
const [tarFileList, setTarFileList] = React.useState([]);
const updateTarFileList=(res)=>{
let list=[];
res.forEach(element => {
list.push(element);
});
setTarFileList(list);
}