0

Recently, I used truffle unbox example: (https://github.com/truffle-box/react-box)

But, I have facing big problem. When I run my App.js with npm run start, It hasn't compile error. However, when I connect my application on web browser, It appear error, like this: enter image description here

I also upgraded my nodejs and npm version, but all my attempting is fail.

My nodejs version is 7.10.1 and npm version is 6.4.1.

Why does this error occur? and what is the solution to solve this problem?

TylerH
  • 20,799
  • 66
  • 75
  • 101
DONG-JIN LEE
  • 113
  • 12
  • Maybe post some code? web3 behaves in a weird fashion, and is async, so if you try to use it before it's ready, it'll error out in weird ways. Truffle does something like `const web3 = await getWeb3();` Also, don't use `componentWillMount` since it's considered legacy, try `componentDidMount` instead: https://reactjs.org/docs/react-component.html#unsafe_componentwillmount – Predrag Beocanin Dec 09 '18 at 16:55
  • Thanks, Predrag. As you said, I try to use componentDidMount function, but It still doesn't work. I'll keep going until solve this problem. – DONG-JIN LEE Dec 10 '18 at 01:59
  • 1
    I finally solve my problem. My source code is written some bugs, and you give me some hint to solve this problem. Thank you – DONG-JIN LEE Dec 12 '18 at 05:53
  • no problem! Maybe answer your question with the solution, so others can find it too? – Predrag Beocanin Dec 12 '18 at 07:26

1 Answers1

0

What worked for me was calling getWeb3 as a function, then chaining the then. so instead of getWeb3.then, it's getWeb3().then.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57