React js hooks sets always one step behind the first call appears as empty the second with the data, I want the first call return the array.
const [test, setTest] = useState([])
async function array(){
const array = [
{id:1},
{id:2},
{id:3},
]
setTest(array)
console.log("ARRAY TEST",test)//the first call appears as empty the second with the data
}