I got empty array after I tried to web3.eth.getAccounts().then(console.log);
and also got a warning which is./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: the request of a dependency is an expression
. In this project I first commanded create-react-app lottery_react
and then all I changed in my lottery_react
folder are modifying App.js
with only one line web3.eth.getAccounts().then(console.log);
and creating web3.js
file. I can't find what's wrong in these file. Please help!
I've seen this and this but we all face different kinds of problem.
This is my App.js
import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import web3 from './web3';
class App extends Component {
render(){
web3.eth.getAccounts().then(console.log);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
}
export default App;
This is my web3.js file
import Web3 from 'web3';
const web3 = new Web3(window.web3.currentProvider);
export default web3;