简体   繁体   English

React 未被识别为导入 - ReactNative expo 应用程序

[英]React not being recognized as imported - ReactNative expo app

Attempting to build an expo app (on my android device) and keep running into this Can't find variable: React error尝试构建一个 expo 应用程序(在我的 android 设备上)并继续遇到这个Can't find variable: React错误

My import statement is import React, { useReducer, useMemo, useEffect, createContext } from 'react';我的导入语句是import React, { useReducer, useMemo, useEffect, createContext } from 'react'; which seems to be correct from previous use and work.从以前的使用和工作来看,这似乎是正确的。 Wondering what could have triggered this problem after an admittedly long code rewrite.想知道在一段公认的长代码重写之后是什么引发了这个问题。 If you want to look at the full file I will link it in a pastebin below如果您想查看完整文件,我会将其链接到下面的粘贴箱中

https://pastebin.com/wXyhHf2v https://pastebin.com/wXyhHf2v

Relevant sections I assumed would be wherever I call a subfunction of React, (like useReducer) as the React context may be needed inside the jsx, but not entirely sure how to fix this.我假设的相关部分是我调用 React 的子函数(如 useReducer)的地方,因为 jsx 中可能需要 React 上下文,但不完全确定如何解决这个问题。

I am not sure what is happening here but it happened to me once and I just made sure that我不确定这里发生了什么,但它发生在我身上一次,我只是确保

import React from 'react'从“反应”导入反应

is the first line of the file.是文件的第一行。 This fixed it for me.这为我修好了。 I can hope it works for you too.我希望它也对你有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM