小编Oli*_*r D的帖子

Android 应用程序无法构建 - 在依赖项的 androidx.work:work-runtime:2.7.0-beta01 中指定的 minCompileSdk (31)

我正在尝试在我的 M1 中构建一个项目,

但当我运行时出现此错误npx react-native run-android

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > The minCompileSdk (31) specified in a
     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
     is greater than this module's compileSdkVersion (android-30).
     Dependency: androidx.work:work-runtime:2.7.0-beta01.
     AAR metadata file: /Users/macpro/.gradle/caches/transforms-3/999e9d813832e06d8f1b7de52647a502/transformed/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
Run Code Online (Sandbox Code Playgroud)

Android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "30.0.0"
        minSdkVersion = 21
        compileSdkVersion = …
Run Code Online (Sandbox Code Playgroud)

android gradle

53
推荐指数
5
解决办法
13万
查看次数

如何强制 React Native 应用程序只是 RTL?

我有一个应用程序是用 React Native 编写的,应用程序中的所有内容都使用“阿拉伯语言和布局”

所以我想强制应用程序也是 RTL 和布局,所以我使用来自 RN 的 I18nManager 来完成它并且它在调试版本中工作正常“当我的移动语言 LTR 或 RTL 工作完美时”

/**
 * @format
 */

import {AppRegistry, I18nManager} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

I18nManager.forceRTL(true);

AppRegistry.registerComponent(appName, () => App);
Run Code Online (Sandbox Code Playgroud)

但是当我为 Play 商店发布 apk 版本时,当我的移动语言 RTL“阿拉伯语”布局和其他工作正常时,但是当我的移动语言为 LTR“英语”时,布局会发生变化和所有事情

所以我想强制我的应用程序成为 RTL,无论是移动语言“阿拉伯语还是英语”

android android-layout android-studio react-native

11
推荐指数
1
解决办法
3910
查看次数

重新获取查询不起作用 - React Query

我试图在一次成功后重新获取一些查询,但它不起作用!

我用了两种方法来处理它:使用refetchQueries()/invalidateQueries()

1-onSuccess回调

export const useMutateAcceptedOrder = () => {
  const queryClient = useQueryClient();
  return useMutation(
    ['AcceptedOrder'],
    (bodyQuery: AcceptedOrderProps) => acceptOrder(bodyQuery),
    {
      onSuccess: () => {
        console.log('success, refetch now!');
        queryClient.invalidateQueries(['getNewOrders']); // not work
        queryClient.refetchQueries(['getNewOrders']); // not work
      },
      onError: () => {
        console.error('err');
        queryClient.invalidateQueries(['getNewOrders']); // not work
      },
    },
  );
};
Run Code Online (Sandbox Code Playgroud)

第二种方式

 const {mutateAsync: onAcceptOrder, isLoading} = useMutateAcceptedOrder();
 const acceptOrder = async (orderId: string) => {
    const body = {
      device: 'iPhone',
      version: '1.0.0',
      location_lat: '10.10',
      location_lng: …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-query

8
推荐指数
1
解决办法
6054
查看次数

在 React Native 中生成多个 APK?

我在 Android 中生成 APK 时遇到一些问题,我正在使用此命令在我的本机项目中生成一个版本

./gradlew assembleRelease
Run Code Online (Sandbox Code Playgroud)

发布后我得到了不止一个APK,

APK

那是什么?哪一个是对的!

我试图在我的真实设备上运行它,但每一个都崩溃了!

版本反应原生:“0.59.8”

在这里文件app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations …
Run Code Online (Sandbox Code Playgroud)

javascript android android-studio react-native react-native-android

5
推荐指数
1
解决办法
2833
查看次数

无法打开,因为您没有查看权限 - React Native - Expo?

使用 弹出 Expo 项目后expo eject,尝试使用 Xcode“11.7”和命令行“For iOS ”运行项目

我收到了这些错误,

笔记:

Android 弹出后运行良好

iOS 和 Android 在弹出之前运行良好。

Xcode

Details

The file “MyApp” couldn’t be opened because you don’t have permission to view it.
Domain: NSCocoaErrorDomain
Code: 257
Failure Reason: You don’t have permission.
Recovery Suggestion: To view or change permissions, select the item in the Finder and choose File > Get Info.
User Info: {
    NSFilePath = "/Users/username/Library/Developer/Xcode/DerivedData/MyApp-bnfffrwsrhskljawuujrmpuwldgt/Build/Products/Debug-iphonesimulator/MyApp.app";
}
--
The operation couldn’t be completed. Permission denied
Domain: NSPOSIXErrorDomain …
Run Code Online (Sandbox Code Playgroud)

xcode ios react-native expo

5
推荐指数
1
解决办法
1443
查看次数

如何在 macOS 上使用 iterm 作为默认终端?

我想让 iTerm2 作为我在 macOS 上的默认终端,

我打开 iTerm2 并点击 make iTerm default Term

但它不起作用!

我转到默认终端首选项

TE

但是打开后我看到了这个 呃

macos shell terminal iterm2

4
推荐指数
2
解决办法
1万
查看次数

如何在反应导航中有条件地隐藏 Tab?

如果用户登录,我想有条件地隐藏我的选项卡之一,

所以我有 5 个选项卡如果用户登录\注册我从 redux 商店得到一个布尔值,如果这个用户登录我想如何“库选项卡”如果没有登录,我不想与其他人一起显示这个选项卡“库”只需在应用程序中保留 4 个标签

代码

import {createAppContainer} from 'react-navigation';
import {createBottomTabNavigator} from 'react-navigation-tabs';

let {isLogin} = store.getState().user;


const TabHome = createBottomTabNavigator(
  {
    Home: {
      screen: Home,
      navigationOptions: {
        tabBarLabel: 'Home',
      },
    },
    Browse: {
      screen: Browse,
      navigationOptions: {
        tabBarLabel: 'Browse',
      },
    },
    Search: {
      screen: Search,
      navigationOptions: {
        tabBarLabel: 'Search',
        headerShown: false,
      },
    },
    Radio: {
      screen: Radio,
      navigationOptions: {
        tabBarLabel: 'Radio',
      },
    },
    Library: isLogin ? (
      {
        screen: YourLibrary,
        navigationOptions: {
          tabBarLabel: 'Library',
        }, …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-android react-navigation

2
推荐指数
1
解决办法
2728
查看次数

无法从不同组件的函数体内部更新组件 - React Native?

我有一个子组件“文本输入”并将值传递给像这样的道具

export default function MobileInput(props) {
  const [mobileNumber, setMobileNumber] = React.useState('');

  return (
    <View style={styles.inputBox}>
        <TextInput
          value={mobileNumber}
          onChangeText={(number) => setMobileNumber(number)}
          onEndEditing={props.saveMobileNumber(mobileNumber)} // here
        />
    </View>
  );
}
Run Code Online (Sandbox Code Playgroud)

在父母中,我从孩子那里得到了价值

const [mobile, setMobile] = useState('');


const getMobile = (number) => {
    number ? setMobile(number) : null; // here's I got this warnning
    console.log('getMobile-number-from-child', number);
  };


const reSendMobile = () => { // other function I want to call passed on mobile number I got from child component 
    if (mobile?.length) {
      alert('Done');
      setReSend(false); …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native

2
推荐指数
1
解决办法
3781
查看次数

获取查询时数据未更新 - React-Query?

我有一个三复选框类型,

当我选中任何框时,我会拨打refetch()电话useEffect()。第一次,我选中所有复选框并返回预期数据!

用户界面

但对于某些“随机重新更改复选框”的情况,API 返回的数据是“未定义”的,尽管它返回了Postman中的预期数据

queryKey所以我想我是否需要为我想要获取的每个数据提供一个唯一的

所以我提供了一个随机值“Date.now()”但仍然返回未定义

代码片段

 type bodyQuery = {
    product_id: number;
    values: {};
  };
  const [fetch, setFetch] = useState<number>();
  const [bodyQuery, setBodyQuery] = useState<bodyQuery>({
    product_id: item.id,
    values: {},
  });

 const {
    data: updatedPrice,
    status,
    isFetching: loadingPrice,
    refetch,
  } = useQuery(
    ['getUpdatedPrice', fetch, bodyQuery],
    () => getOptionsPrice(bodyQuery),
    {
      enabled: false,
    },
  );

  console.log('@bodyQuery: ', bodyQuery);
  console.log('@status: ', status);
  console.log('@updatedPrice: ', updatedPrice);

  useEffect(() => {
    if (Object.keys(bodyQuery.values).length > 0) …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-query

2
推荐指数
1
解决办法
9300
查看次数

无法在反应导航堆栈中居中标题 - React-Native?

我无法在 react-navigation V4+ 中将标题居中,在使用 v3 之前它的工作正常,当使用 RN-stack 时,由于某种我不知道的原因,我无法将标题居中。

它只是出现在右边,

我尝试这些中headerTitleStyleheaderStyle

justifyContent, alignItems and alignSelf but not works :/
Run Code Online (Sandbox Code Playgroud)

如果你有任何想法告诉我?

"react-navigation": "^4.0.10",
"react-navigation-drawer": "^2.3.3",
"react-navigation-stack": "^2.0.16",
"react-native-screens": "^2.0.0-alpha.29",
Run Code Online (Sandbox Code Playgroud)

这是代码

static navigationOptions = ({navigation}) => {
    const showModal = navigation.getParam('showModal', () => {});
    return {
      title: navigation.getParam('title'),
      headerTitleStyle: {
        fontFamily: 'Cairo-Regular',
        fontSize: Platform.OS == 'ios' ? 16 : 18,
        color: '#fff',
        flex: 1,
        textAlign: 'center',
      },
      headerStyle: {
        backgroundColor: navigation.getParam('color'),
      },
      headerRight: (
        <Grid>
          <Row>
            <Body>
              <Button
                transparent
                icon …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-navigation react-navigation-stack

1
推荐指数
1
解决办法
2574
查看次数