Lesson 10: Trouble understanding destruct pattern with useWeb3Contract #1423
-
I am looking at React code where we call useWeb3Contract hook, which I kind of understand but not really
I get that we pass on the right side of equation parameters for useWeb3Contract function and on the left we should get(destruct?) results from it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
when we say const {runContractFunction: enterRaffle}=useWeb3Contract({}) we are getting Another example is: let users={
name:"John",
address:2
}
//if we want the name we will say
let {name}=users
//if we want to be more explicit we will change name to username.like this:
let {name:username}=users
//when destructuring basically we are getting the individual item in object directly .In above example if would have said:
let username=users.name
//it is just the same thing only that destructuring is cleaner way of doing it about calling |
Beta Was this translation helpful? Give feedback.
when we say
we are getting
runContractFunction
fromuseWeb3Contract
hook.But lets say there are other five functions that are going to interact with the contract in this same page they will have the same name ofrunContractFunction
,so we rename it toenterRaffle
.so from now our function will no longer be calledrunContractFunction
.It will beenterRaffle
.Another example is: