react-native 中的 web3:无法读取 属性 'getReader'
web3 in react-native : Cannot read property 'getReader'
版本
"web3": "^1.2.1"
"react-native": "0.59.10"
从 set-up tutorial and https://github.com/ethereum/web3.js/issues/1022 开始,我能够在 react-native
中安装 web3
,但是我得到了这个错误:
错误
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)
当我使用像 web3.eth.getTransactionCount
或 web3.eth.getBlock('latest')
这样的 promise 方法时发生错误。
尝试
我试过了console.log(web3.version)
,一点问题都没有
经过深入搜索,我发现使用 web3@1.0.0-beta.34
比 react-native
更稳定,所以问题提到的问题不再出现。问题解决=)
版本
"web3": "^1.2.1"
"react-native": "0.59.10"
从 set-up tutorial and https://github.com/ethereum/web3.js/issues/1022 开始,我能够在 react-native
中安装 web3
,但是我得到了这个错误:
错误
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)
当我使用像 web3.eth.getTransactionCount
或 web3.eth.getBlock('latest')
这样的 promise 方法时发生错误。
尝试
我试过了console.log(web3.version)
,一点问题都没有
经过深入搜索,我发现使用 web3@1.0.0-beta.34
比 react-native
更稳定,所以问题提到的问题不再出现。问题解决=)