web3在React原生中:无法读取属性“”

rsl1atfo  于 2023-01-14  发布在  React
关注(0)|答案(1)|浏览(165)

Version

"web3": "^1.2.1"
"react-native": "0.59.10"
From set-up tutorial and https://github.com/ethereum/web3.js/issues/1022 , I was able to install web3 in react-native , however I got this error:

Error

Possible Unhandled Promise Rejection (id: 1): TypeError: Cannot read property 'getReader' of undefined TypeError: Cannot read property 'getReader' of undefined at new exports.IncomingMessage (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222317:34) at module.exports.ClientRequest._connect (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222201:22) at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222115:14 at tryCallOne (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:45372:14) at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:45473:17 at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46351:21 at _callTimer (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46240:9) at _callImmediatesPass (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46276:9) at Object.callImmediates (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46495:14) at MessageQueue.__callImmediates (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:16572:16)The error occurs when I doing promise method likeweb3.eth.getTransactionCountorweb3.eth.getBlock('latest'). I triedconsole.log(web3.version)` , no problem at all

zyfwsgd6

zyfwsgd61#

我发现使用web3@1.0.0-beta.34对于react-native来说更稳定,所以提到的问题不再出现。

相关问题