使用上下文时超出最大调用堆栈大小和 ENOENT 错误

Maximum Call Stack Size exceeded and ENOENT error while using context

每当我尝试使用 React context、provider 或 useContext 时都会收到此错误,其中任何一个都会导致此问题

在应用程序上:

Maximum call stack exceeded

在终端上:

Error: ENOENT: no such file or directory, open '/home/lck/Desktop/workdir/MathApp/mathapp/http:/192.168.0.4:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mathapp&modulesOnly=false&runModule=true'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at getCodeFrame (/home/lck/Desktop/workdir/MathApp/mathapp/node_modules/metro/src/Server.js:919:18)
    at Server._symbolicate (/home/lck/Desktop/workdir/MathApp/mathapp/node_modules/metro/src/Server.js:992:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Server._processRequest (/home/lck/Desktop/workdir/MathApp/mathapp/node_modules/metro/src/Server.js:403:7) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/lck/Desktop/workdir/MathApp/mathapp/http:/192.168.0.4:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mathapp&modulesOnly=false&runModule=true'
}

上下文路径错误。

基本上我导入ContextFile.js到index.js,并从index.js获取很多东西。 index.js 正在从自身导入 Context,而不是从 ContextFile。

起初我更正文件时没有用,不知道什么时候,我什至用 npx react-native start

重新启动了

非常感谢@Bergi,他说的对我解决问题帮助很大。可悲的是我不知道如何标记或给他发消息。

我希望这对其他人有帮助...

image showing how i structure my files