Type 'undefined' cannot be used as an index type #1363
Replies: 2 comments 4 replies
-
|
Hello there @Kuchy300 |
Beta Was this translation helpful? Give feedback.
-
|
Hello @NarithChesda I know it is pretty old issue but it's still unanswered, so solution for you @NarithChesda is that you have networkMapping[chainId]["DappToken"][0] : constants.AddressZeroinstead of networkMapping[stringChainId]["DappToken"][0] : constants.AddressZero@cromewar unfortunately I do not have screens from my index incorrect type error, but do you have any idea why that error might occur? I have just updated Main.tsx by adding |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What's wrong with this?
It was working just fine, but then it became error... anybody having the same problem?
now I just assign index directly to the networkMapping[ ] to get it working.
noted : I'm doing front-end separately from the contract folder, I just copy the deployment and contract folder from build to src in my front-end project.
Main.tsx
This is my map.json
{ "42": { "DappToken": ["0x7dA443383a8F7FCD3b2f2C473066C39FE3dfcE13"], "TokenFarm": ["0xfe3cbA318740a6312356c129fe83E581dC1a6631"], "WethToken": ["0xd0a1e359811322d97991e03f863a0c30c2cf029c"], "FauToken": ["0xFab46E002BbF0b4509813474841E0716E6730136"] } }my package.json
{ "name": "defi-platform", "version": "0.1.0", "private": true, "dependencies": { "@emotion/react": "^11.8.2", "@emotion/styled": "^11.8.1", "@fontsource/roboto": "^4.5.5", "@mui/icons-material": "^5.5.1", "@mui/material": "^5.5.3", "@mui/styled-engine-sc": "^5.5.2", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.0.0", "@testing-library/user-event": "^13.2.1", "@types/jest": "^27.0.1", "@types/node": "^16.7.13", "@types/react": "^17.0.20", "@types/react-dom": "^17.0.9", "@usedapp/core": "^0.12.2", "ethers": "^5.6.2", "react": "^18.0.0", "react-dom": "^18.0.0", "react-scripts": "5.0.0", "styled-components": "^5.3.5", "typescript": "^4.4.2", "web-vitals": "^2.1.0" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] } }it was working fine when I followed along with the tutorial, but I was having trouble with @usedapp/[email protected] as useTokenBalance and useContractCall always return undefined, so I upgrade @usedapp/core to @0.12.2(latest) and it fixed that problem but it came with this new problem.
Beta Was this translation helpful? Give feedback.
All reactions