Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

someone please explain what gregory said at 1:44:58 to 1:45:12, why passing accounts around like that? #16

Open
elvisisvan opened this issue Feb 13, 2023 · 0 comments

Comments

@elvisisvan
Copy link

elvisisvan commented Feb 13, 2023

what he said word-by-word:
"let's do the exactly same thing, say accounts, await, window, ethereum request get accounts and we're gonna set the accounts to the first account on the list, and then that's gonna set it the in component state of the parent component and we're gonna pass it back in here with this account like this

related code snippets:
App.js

...
function App() {
  const [account, setAccount] = useState(null)

  const loadBLockchainData = async () => {
    const provider = new ethers.providers.Web3Provider(window.ethereum)
     
  }

  useEffect(() => {
    loadBLockchainData()
  })

  return (
    <div>

    <Navigation account={account} setAccount={setAccount}/>

      <div className='cards__section'>

        <h3>Welcome to Millow</h3>

      </div>

    </div>
  );
}
...

Navigation.js

...
const Navigation = ({ account, setAccount }) => {
    const connectHandler = async () =>{
        const accounts = await window.ethereum.request({method: 'eth_requestAccounts'});
        setAccount(accounts[0])        
    }
...

video: https://youtu.be/C4blK6X-D_4?t=6298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant