Closed pawanpaudel93 closed 1 year ago
@martonlederer
Hey, the currently published version appears to work fine with object destructuring. Are you sure this is an issue? Can you upload some screenshots so I can see this error?
@martonlederer
This is the error I get when using any methods from the useApi
hook.
@martonlederer Check the deployed app which shows the above error. It uses the useApi hook to get the active address.
https://arweave-wallet-kit-demo.vercel.app/ https://github.com/pawanpaudel93/arweave-wallet-kit-demo
In #2, I've moved the callWindowApi
function in its own utility file. We'll be merging that soon and we'll see if there are any other issues that this PR would solve, after that change. I'm going to keep this open till then, thank you 😄
@pawanpaudel93 I've just released a beta version of #2 and tested it out in your demo repo and it seems like it works.
Would you also be able to test it? The version is 1.0.1-beta.0
.
Thanks!
Thanks, @martonlederer it works now.
Bug fixed
Here, https://github.com/labscommunity/arweave-wallet-kit/blob/549ed58d06792bed4738d33b13f030d2d7b08876/src/hooks/strategy.ts#L46 Object destructuring is used to extract methods from the strategy instance but the methods lose their original
this
binding. So when any of the methods are used with theuseApi
hook, it givesthis.callWindowApi is not a function error
. So to fix this error, arrow functions are used for the extracted methods.