EatTheBlocks Forum

Misunderstanding at DAY13-Multisig Wallet

Hello Everyone,

I hope you are all well.
In the frontend part in the updateCurrentTransfer function I don’t understand the following line:
setCurrentTransfer({…currentTransfer, alreadyApproved});

Could you explain me what it means please?
I have looked to some online documentation but I still don’t understand.

Here is the entire function:

async function updateCurrentTransfer() {

const currentTransferId = (await contract.methods


  .call()) - 1;

if(currentTransferId >= 0) {

  const currentTransfer = await contract.methods



  const alreadyApproved = await contract.methods

    .approvals(accounts[0], currentTransferId)


  setCurrentTransfer({...currentTransfer, alreadyApproved});



Thank you for your help

Take care


Three dots syntax ( ‘…’ ) is the spread operator in React.
If you do setCurrentTransfer(alreadyApproved) , the resulting state object will just be { alreadyApproved: alreadyApproved}. The new value is not merged into the old one, it is just replaced.
setCurrentTransfer({…currentTransfer, alreadyApproved}) would give you your original state object and only update the one thing you changed.

Thank you very much :slight_smile: