标签: react-native-android

在 React Native 和 Android 之间共享 Realm 实例

我正在开发一个使用 Realm for React Native 的 React Native 项目。它可以正常工作,但现在,我面临编写将使用相同 Realm 实例的 Android 服务的问题。有可能吗,我该怎么做?

realm react-native-android

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

得到'其中一个来源是在React原生应用上的原型链上有一个可枚举的键

我正在使用react-native for Android app.并axios用作http库.当我尝试Blob通过http帖子发送对象时,我将得到以下错误:

HTTP Failure in Axios TypeError: One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property? We don't allow it, as this is an edge case that we do not support. This error is a performance optimization and not spec compliant.
Run Code Online (Sandbox Code Playgroud)

下面是我用来在表单数据上添加blob对象的代码:

let data = new FormData()
  data.append('image', decodeBase64Image(image));
Run Code Online (Sandbox Code Playgroud)

下面是解码base64图像的代码.以下代码在我的一个网站应用程序中正常工作.

export const decodeBase64Image = (dataURI) => {
  let byteString;
  if (dataURI …
Run Code Online (Sandbox Code Playgroud)

android react-native react-native-android

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

React-Native-TextInput光标位于Android的中间而不是顶部

我正在TextInput我的本机应用程序中渲染一个高度为100像素的。在Android中,用于输入文本的光标显示在中间,而不是顶部。光标对于iOS来说看起来不错。以下是演示该问题的草图:

https://sketch.expo.io/SJVIk30ig

的TextInput是使用下面的代码呈现:

<TextInput style={{height: 100, padding: 5, backgroundColor: colorThemes.Blue.lightGrey}} 
          multiline={true}
          value={this.state.value}
          onChange={this.onTextInputChange}
          underlineColorAndroid={'transparent'}
          autoCorrect={true} autoFocus={true}
          autoCapitalize={'sentences'}
        />
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android

5
推荐指数
2
解决办法
5146
查看次数

React Native - 当TextInput中的文本长于TextInput且不在焦点时,三个点

所以我会尝试解释我的情景.

我有一条单线 TextInput.当用户是onFocus,其中的文本TextInput可以比TextInput自己长.

但是,当用户不再使用时onFocus,Android和iOS的行为会有所不同.

iOS: 在行尾添加三个点,并显示文本的开头.

在此输入图像描述

Android: 没有进行任何更改.

Android中的行为

如何让Android中的TextInput像在iOS中一样表现这种特定情况?

谢谢

react-native react-native-android

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

连接到10.0.2.2而不是localhost的React-native android调试器

在运行app时react-native run-android连接到10.0.2.2:8081而不是localhost:8081并且无法调试.

有谁知道如何修复,以便它将连接到localhost而不是?

android-emulator react-native react-native-android react-native-debugger

5
推荐指数
2
解决办法
5467
查看次数

使用React Native App的Android Studio构建错误

我一直在尝试使用expo工具xde使用react native创建一个应用程序,然后使用exp detach分离它,当我在Android Studio中打开时,在构建时会遇到很多错误:

Using incompatible plugins for the annotation processing

Configuration 'compile' is obsolete and has been replaced with
'implementation' and 'api'. It will be removed at the end of 2018.
For more information see:
http://d.android.com/r/tools/update-dependency-configurations.html


The specified Android SDK Build Tools version (23.0.1) is ignored,
as it is below the minimum supported version (27.0.3) for Android
Gradle Plugin 3.1.1. Android SDK Build Tools 27.0.3 will be used. To
suppress this warning, remove "buildToolsVersion '23.0.1'" from your
build.gradle file, …
Run Code Online (Sandbox Code Playgroud)

build.gradle android-gradle-plugin react-native react-native-android android-studio-3.1

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

React Native:手机号码验证仅接受数字值

如何在本机中验证手机号码接受唯一的数值。

 <TextInput
      ref='mobileNo'
      keyboardType="numeric"
      style={[styles.textInput, { width: '100%' }]}
      placeholder='Enter mobile number'
      onChangeText={(value) => this.handleChange('mobileNo', value)}   />
Run Code Online (Sandbox Code Playgroud)

我已经使用过,keyboardType="numeric"但是它也接受特殊字符,因此我想接受唯一的数值。

javascript reactjs react-native react-native-android react-native-ios

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

处理BackHandler

作为RN编程的新手,我正在尝试处理android硬件按钮。但是在屏幕上按下它会导致同时进入上一屏幕并关闭应用程序。我的StackNavigator看起来像:

const navigatorApp = StackNavigator({
  Screen1: { screen: Screen1 },
  Screen2: { screen: Screen2 },
  Screen3: { screen: Screen3 },
  Screen4: { screen: Screen4 }
})
Run Code Online (Sandbox Code Playgroud)

我试图对诸如

class HandleHavigation extends React.Component {
  componentWillMount () {
    if (Platform.OS === 'android') return
    BackHandler.addEventListener('hardwareBackPress', () => {
      const { dispatch, nav } = this.props
      if (nav.routes.length === 1 && (nav.routes[0].routeName === 'Screen1')) {
        return false
      }
      dispatch({ type: 'Navigation/BACK' })
      return true
    })
  }
  componentWillUnmount () {
    if (Platform.OS === 'android') return
    BackHandler.removeEventListener('hardwareBackPress') …
Run Code Online (Sandbox Code Playgroud)

android reactjs react-native react-native-android react-native-navigation

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

如何在React Native中创建自定义可折叠标头?

以下是我要实现的演示屏幕。

在此处输入图片说明

因此,我想做的是,当我向上滑动绿色区域时,我希望黄色区域与之同时向上移动,以及下面的蓝色框区域(FlatList在我的情况下)。

当黄色区域最终被隐藏时,我希望绿色区域停留在屏幕顶部,并且用户可以在下面的蓝色框区域中滚动。

如何使用API PanResponder和AnimatedAPI?据我所知,可以使用插值来完成,但是在这种情况下我无法获得逻辑。

reactjs react-native react-native-android react-native-animatable

5
推荐指数
0
解决办法
642
查看次数

反应本机redux连接未定义的功能

我有下面的代码库

博览会链接

https://snack.expo.io/@mparvez19861/redux-example

app.js

 <Provider store={store}>
                <View style={styles.container}>
                    <Navigator />
                </View>
            </Provider>
Run Code Online (Sandbox Code Playgroud)

Navigator.js

const AuthStack = createStackNavigator({
  // { SignIn: SignInScreen }
  // SignIn: { screen: EmailPwdLogin }
    Login: { screen: LoginScreen },
    Signup: { screen: SignupScreen },
  });
const drNav = createDrawerNavigator(
  {

    Screen2: {
        screen: Screen2
      },
     SignOut: {
      screen: SignOutScreen
    }
  }
)

export default createAppContainer(createSwitchNavigator(
  {
    // screendesign: screendesign,
    SplashScreen: SplashScreen,
    App: drNav,
    AuthStack: AuthStack
  },
  {
    initialRouteName: 'SplashScreen',
  }
));
Run Code Online (Sandbox Code Playgroud)

login.js

  import React, { Component …
Run Code Online (Sandbox Code Playgroud)

react-native redux react-redux react-native-android

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