我应该避免重新渲染。那么为什么这段代码不起作用呢?
RenderItem 不是函数。
import React, { memo, useMemo } from 'react';
import { StyleSheet, Text, View, FlatList, TextInput, TouchableOpacity, Image, Dimensions } from 'react-native';
const Shopping_cart = ({ datas, onPressSetting }) => {
  const RenderItem = useMemo((item) => {
    return (
      <Text>Hello</Text>
    )
  }, [datas]);
  return (
    <FlatList 
      data={datas}
      keyExtractor={item => item.item.product_id}
      renderItem={({ item }) => RenderItem(item)}
    />
  )
};
Run Code Online (Sandbox Code Playgroud) 有人知道如何在 React 本机博览会应用程序中禁用分屏吗?我在文档中找到了这个解决方案,但仅适用于 ios。预先非常感谢
Open your app.json and add the following inside of the "expo" field:
{
  "expo": {
    ...
    "ios": {
      ...
      "requireFullScreen": true,
    }
  }
}
Run Code Online (Sandbox Code Playgroud) 当我使用这一行时,我收到此错误:
eas build -p android
我正在尝试构建项目,但它给出了此错误:
    Error: Cannot copy 'C:\Users\xx' to a subdirectory of itself,
    'C:\Users\xx\AppData\Local\Temp\eas-cli-nodejs\5897d1cd-52ae-4c3c-a5c4-577
    69487c9f8-shallow-clone'
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用react-native-reanimated让一些组件在安装和卸载时淡入淡出。我认为代码非常简单:
import { View } from "react-native";
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
export const Dialog = () => (
  <Animated.View
    style={styles.loadingWrapper}
    entering={FadeIn}
    exiting={FadeOut}
  >
    <Progress.CircleSnail />
  </Animated.View>
);
const App = () => {
  const [isVisible, setIsVisible] = useState(false);
  return (
    <View>
      {isVisible && <Dialog />}
      <Button 
        title="Open Dialog" 
        onPress={() => setIsVisible(true)}
      />
    </View>
  );
}
Run Code Online (Sandbox Code Playgroud)
我的期望是,随着isVisible道具的变化,它Dialog会淡入淡出。正在发生的事情是它突然出现又消失,就好像我使用的是简单的View,而不是Animated.View.
我无法在小吃中重现这个问题。在零食中它似乎效果很好。在我的实际代码库中,这只是一个稍微分层的版本,没有动画。我怎样才能开始调试这个?
我的应用程序中的所有实例都是这种情况Animated.View。我让它在某个时候工作,然后在这个过程中的某个地方,它停止工作了。我不确定发生了什么变化。我正在使用世博会管理的项目。这是我的 package.json 和版本的相关部分:
{
  "scripts": {
    "start": "expo …Run Code Online (Sandbox Code Playgroud) react-native expo react-native-reanimated react-native-reanimated-v2
我正在使用 Expo、EAS Build 创建一个适用于 Android 的 React Native 应用程序。
按照此处的文档,我为我的应用程序设置了通知,包括 Firebase Cloud Messaging。
在我的代码(主要取自文档)中,我使用 UseEffect 在应用程序启动时检查通知权限,如果应用程序没有权限,我会请求权限。
但是,当我在开发服务器上加载应用程序时,会弹出警报,指出“无法获取推送通知的推送令牌!”
为了确保其他一切正常工作,我通过设置在我的设备上手动启用了通知权限。然后,该应用程序运行良好。我正在安排工作的通知。没有问题。
但显然,我不希望用户必须手动进入设置。我希望出现提示。
这是否是开发服务器的问题,一旦部署就不再存在?
任何帮助表示赞赏。谢谢。
以下是我认为来自我的 App.js 的相关代码。我希望用户第一次打开应用程序时会出现提示,要求他们授予通知权限。
import * as Notifications from "expo-notifications";
// other import statements
Notifications.setNotificationHandler({
  handleNotification: async () => {
    return {
      shouldShowAlert: true,
      shouldPlaySound: true,
      shouldSetBadge: true,
    };
  },
});
// other code
export default function App() {
// other code
const notificationListener = useRef();
const responseListener = useRef();
useEffect(() => {
    registerForPushNotificationsAsync().then(token => setExpoPushToken(token));
    // This listener …Run Code Online (Sandbox Code Playgroud) permissions reactjs react-native firebase-cloud-messaging expo
我目前正在使用 Expo CLI 从头开始开发 React Native 应用程序。
我使用 AWS Amplify 设置后端。部署和拉取已完成,一切就位。我在项目根目录中有放大文件夹。我的 ./src 文件夹中有 aws-export.js 。还安装了必要的库。
现在一切准备就绪,可以使用 AWS Amplify 将我的 React Native 项目连接到后端。
根据文档,我导入了 Amplify 和 config。
但是在我放置此行后,Amplify.configure(config);我在终端中收到此错误:TypeError: undefined is not an object (evaluating '_awsAmplify.default.configure')
所以当输入这行代码时就会发生这种情况:
Amplify.configure(config);
Run Code Online (Sandbox Code Playgroud)
如果我注释掉这一行,一切都好。
App.js 非常简单:
import { View, Text } from "react-native";
import Amplify from "aws-amplify";
import config from "./src/aws-exports";
Amplify.configure(config);
const App = () => {
  return (
    <View>
      <Text>Hello World</Text>
    </View>
  );
};
export default App;
Run Code Online (Sandbox Code Playgroud)
我认为依赖关系之间存在一些不兼容。
这是我的 package.json: …
在尝试使用 expo 构建 .apk 文件时,我收到此错误:
[标准错误] npm
[标准错误] 错误!代码 ERESOLVE
[标准错误] npm
[标准错误] 错误!ERESOLVE 无法解决
[stderr] npm 错误!
[标准错误] npm
[标准错误] 错误!解析时:@react-native-google-signin/google-signin@8.2.1
[标准错误] npm
[标准错误] 错误!找到:@expo/config-plugins@5.0.4
[stderr] npm 错误!node_modules/@expo/config-plugins
[stderr] npm 错误!来自根项目的 @expo/config-plugins@"^5.0.4"
[stderr] npm 错误!
[stderr] @expo/config-plugins@"~5.0.3" 来自 @expo/cli@0.4.9
[stderr] npm 错误!节点模块/@expo/cli
[stderr] npm 错误!@expo/cli@"0.4.9" 来自 expo@47.0.5
[stderr] npm 错误!节点模块/博览会
[stderr] npm 错误!来自根项目的 expo@"~47.0.5"
[stderr] npm 错误!另外 12 个(expo-application、expo-constants、expo-dev-client,...)
[stderr] npm 错误!另外 5 个(@expo/config、@expo/prebuild-config,...)
[stderr] npm 错误!
[stderr] npm 错误!无法解决依赖关系:
[stderr] npm 错误!来自@react-native-google-signin/google-signin@8.2.1的peerOptional @expo/config-plugins@"^4.1.0"
[stderr] npm 错误!node_modules/@react-native-google-signin/google-signin
[stderr] npm …
我在我的 React Native expo 应用程序中使用expo-router,我的文件是
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 (main)\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 _layout.js\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 _foo.js\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 _bar.js\nRun Code Online (Sandbox Code Playgroud)\nlayout.js
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 (main)\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 _layout.js\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 _foo.js\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 _bar.js\nRun Code Online (Sandbox Code Playgroud)\n但是,我的 iOS 设备上显示的 2 个选项卡按钮有标题foo和bar而不是Foo和Bar。
设置选项卡按钮名称的正确方法是什么?
\n另外,有没有办法重新排列选项卡按钮的顺序?例如显示[ Foo | Bar ]而不是[ Bar | Foo ]. 谢谢!
我不断收到此错误。我的应用程序已经完美工作了好几天,但我在环境文件方面遇到了一些问题,所以我完全重新安装并清理了我的缓存。现在,每当我尝试构建应用程序时,我都会收到此错误:
src\images\avatar.jpg: assetUrlPath.replaceAll is not a function
Run Code Online (Sandbox Code Playgroud)
这不仅发生在图像上,我的字体也遇到了这个错误:
node_modules\@expo-google-fonts\montserrat\Montserrat_400Regular.ttf: assetUrlPath.replaceAll is not a function
Run Code Online (Sandbox Code Playgroud)
我已经删除了node_modules,删除了package-lock.json,再次清除了缓存,重新安装,重新安装了expo,什么也没有。
更重要的是,当你将错误输入谷歌时,你会得到零的反应本机结果。我做错了什么?
我使用的"react-native": "0.72.3"是 Xcode 14,一切都运行良好,但是当我将 Xcode 更新到Xcode 15时。然后它给出如下错误
注意:我使用的是 Live Activity 和 Dynamic Island 小部件扩展以及两个通知小部件扩展。
\nShowing Recent Messages\nCycle inside <Target>; building could produce unreliable results.\nCycle details:\n\xe2\x86\x92 Target \'<Target>\': ExtractAppIntentsMetadata\n\xe2\x97\x8b Target \'<Target>\' has copy command from \'/Users/apple/Library/Developer/Xcode/DerivedData/<Target>-hifbytcglbabrcgbkmfgnzgmwpmj/Build/Products/Debug-iphoneos/LiveActivityDynamicIslandExtension.appex\' to \'/Users/apple/Library/Developer/Xcode/DerivedData/<Target>-hifbytcglbabrcgbkmfgnzgmwpmj/Build/Products/Debug-iphoneos/<Target>.app/PlugIns/LiveActivityDynamicIslandExtension.appex\'\n\xe2\x97\x8b That command depends on command in Target \'<Target>\': script phase \xe2\x80\x9c[CP-User] [RNFB] Core Configuration\xe2\x80\x9d\n\xe2\x97\x8b Target \'<Target>\' has process command with output \'/Users/apple/Library/Developer/Xcode/DerivedData/<Target>-hifbytcglbabrcgbkmfgnzgmwpmj/Build/Products/Debug-iphoneos/<Target>.app/Info.plist\'\n\xe2\x97\x8b Target \'<Target>\' has copy command from \'/Users/apple/Library/Developer/Xcode/DerivedData/<Target>-hifbytcglbabrcgbkmfgnzgmwpmj/Build/Products/Debug-iphoneos/LiveActivityDynamicIslandExtension.appex\' to \'/Users/apple/Library/Developer/Xcode/DerivedData/<Target>-hifbytcglbabrcgbkmfgnzgmwpmj/Build/Products/Debug-iphoneos/<Target>.app/PlugIns/LiveActivityDynamicIslandExtension.appex\'\nRun Code Online (Sandbox Code Playgroud)\n\n 实际上,根据我的知识,我是反应本机的初学者,我有两种安装反应本机的选项,即反应本机 CLI 和 Expo CLI。我很困惑哪个更适合初学者安装和使用React Native 应用程序开发,哪个对初学者有更多的支持
reactjs react-native react-native-android react-native-navigation expo
我正在尝试使用 EAS 构建构建我的 Expo(托管工作流程)应用程序:
eas build -p ios
Run Code Online (Sandbox Code Playgroud)
它失败并出现以下错误(expo.dev /构建详细信息):
Installing pods
Using Expo modules
Auto-linking React Native modules for target `livehere`: RNCClipboard, RNCMaskedView, RNDateTimePicker, RNGestureHandler, RNReanimated, RNSVG, RNScreens, RNSentry, react-native-maps, react-native-safe-area-context, and react-native-segmented-control
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
[Codegen] Found FBReactNativeSpec
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`
[!] Unable to add a source with …Run Code Online (Sandbox Code Playgroud) expo ×12
react-native ×11
reactjs ×3
ios ×2
javascript ×2
aws-amplify ×1
cocoapods ×1
firebase ×1
permissions ×1
xcode ×1
xcode15 ×1