Hi guys,
I have a state const [arrayAddress, setArrayAddress] = useState([]);
and I set the arrayAddress when I call my contract :
<Button
text='Ajouter le voter'
theme='primary'
type='button'
icon='arrowCircleDown'
onClick={async () =>
await voting({
onSuccess: (mess) => {
setArrayAddress((prevArray) =>[...prevArray, address])
handleSuccess(mess, 'info', `L\'adresse ${address} a bien été ajouté`, 'Ajout d\'une nouvelle adresse', 'bell')
console.log(mess)
console.log('array',arrayAddress)
},
onError: (err) => {
handleError(err, `${err.error ? err.error.message : err}`, 'Erreur', 'xCircle')
}
})
}
/>
Then I display it. Everything works except when I refresh the page, my arrayAddress is empty !
So it means I’ve got the data in the blockchain but at the initialization I don’t have the info in my arraAddress and I should get the it from my contract and set it ( this is what I think, maybe I’m wrong)
But I don’t know how to do it, any idea ?