当我使用React Native开发混合应用程序时.当我从React Native代码创建Android-App时,我编写的JavaScript代码是否会转换为Dalvik/ART Runtime的Java-Code或Java-Bytecode?或者只是编译为本机UI组件的UI组件?或者像Fetch API这样的库是否将JavaScript代码编译成Java-Code或Java-Bytecode?
我刚刚安装了node.js和cli
安装了react-native-cli
npm -g react-native-cli
Run Code Online (Sandbox Code Playgroud)并创建了一个“新项目”。
react-native init new_project
Run Code Online (Sandbox Code Playgroud)在“ new_project”目录中,我很疲倦地查看Metro bundler是否运行良好。
react-native start
Run Code Online (Sandbox Code Playgroud)但是该命令给了我以下错误,并且Metro无法启动。有任何解决此错误的线索吗?(我正在使用Windows 10 OS。)
C:\projects\new_proj>react-native start
错误无效的正则表达式:/(.\fixtures.|node_modules[]react[]dist[].|website\node_modules.|heapCapture\bundle.js|.\tests。)$/:未终止的字符类。使用--verbose标志运行CLI以获取更多详细信息。SyntaxError:无效的正则表达式:/(..fixtures.|node_modules[]react[]dist[].|website\node_modules.|heapCapture\bundle.js|.\tests.)$/:新RegExp( )在getBlacklistRE(D:\ projects \ new_proj \ node_modules \ react-native \ node_modules @ react-native)的黑名单(D:\ projects \ new_proj \ node_modules \ metro-config \ src \ defaults \ blacklist.js:34:10) getDefaultConfig上的-community \ cli \ build \ tools \ loadMetroConfig.js:69:59)(D:\ projects \ new_proj \ node_modules \ react-native \ node_modules @ react-native-community \ cli \ build \ tools \ loadMetroConfig.js :85:20)在负载(D:
reactjs react-native react-native-android react-native-cli metro-bundler
我在使用react-native onPress功能时遇到问题.onPress应该仅在触摸事件(我猜)实际触发时才有效,即当我按下屏幕上的按钮时.但是当调用render函数时,似乎onPress会被触发.当我尝试手动按下时,它不起作用.
import React, { Component } from 'react';
import { PropTypes, Text, View ,Alert } from 'react-native';
import { Button } from 'react-native-material-design';
export default class Home extends Component {
render() {
return (
<View style={{flex:1}}>
<Button value="Contacts" raised={true} onPress={this.handleRoute('x')} />
<Button value="Contacts" raised={true} onPress={this.handleRoute('y')} />
<Button value="Contacts" raised={true} onPress={this.handleRoute('z')} />
</View>
);
}
handleRoute(route){
alert(route) // >> x , y, z
}
}
module.exports = Home;
Run Code Online (Sandbox Code Playgroud)
我错过了什么?我分配的方式有什么问题,或者这是一些错误吗?任何建议都非常感谢.
我正在尝试使用插值动画查看.我想得到我的Animated.Value的当前值,但不知道如何.我不明白如何使用React-native docs.
this.state = {
translateAnim: new Animated.Value(0)
}
DeviceEventEmitter.addListener('Accelerometer', function (data) {
console.log(this.state.translateAnim);
// returns an object, but I need a value in current moment
}
Run Code Online (Sandbox Code Playgroud) 我<select>在Android平板电脑上使用HTML 标签在React Native的WebView中遇到了一个非常奇怪的问题.出于某种原因,点击渲染<select>按钮不会打开选项列表.
这只发生在Android平板电脑上,无论Android版本如何.但是,在Android智能手机上,不会发生此错误,并且选项列表会按预期打开.
为了重现这个bug,我创建了一个简单的演示应用程序:https://github.com/huonderv/react-native-webview-html-select-bug.
重要的代码如下:
index.android.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
WebView
} from 'react-native';
export default class WebViewProject extends Component {
render() {
return (
<WebView
style={styles.container}
source={{ uri: 'file:///android_asset/simpleselect.html'}}
startInLoadingState={true}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
AppRegistry.registerComponent('WebViewProject', () => WebViewProject);
Run Code Online (Sandbox Code Playgroud)
simpleselect.html
<!DOCTYPE html>
<html>
<body>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option> …Run Code Online (Sandbox Code Playgroud) javascript android android-webview react-native react-native-android
我不想撰写电子邮件.我只是希望能够从反应原生的应用程序在用户的设备(iOS和Android)上启动主电子邮件应用程序.
场景:我会在注册时向用户发送验证电子邮件.
我试图在android中的expo应用程序上运行create-react-native-app.
首先,我通过编写命令创建了项目
create-react-native-app test
然后我执行了
npm开始
然后从expo app扫描qr代码.
但扫描QR码后,我收到以下错误:
Uncaught Error: Java.net,sockettimeoutException: failed to connect to after 10000ms
Run Code Online (Sandbox Code Playgroud)
Github问题:
https://github.com/react-community/create-react-native-app/issues/144#issuecomment-296631692
react-native react-native-android expo create-react-native-app
我今天开始收到此错误,昨天一切正常,gradle或firebase版本没有变化
com.google.firebase库:firebase-iid正在[[17.0.0,17.0.0]]的各个其他库请求,但解析为16.2.0.禁用插件并使用./gradlew:app:dependencies检查依赖关系树.
我看到昨天是谷歌服务插件的更新,可能是导致问题.
如何解决这个问题?
android google-play-services android-gradle-plugin react-native react-native-android
我正在尝试使用KeyboardAvoidingView with behavior ="padding".
出于某种原因,当我尝试在TextInput中输入任何文本时,空间将位于TextInput下方.随附的是正在发生的事情以及代码.有没有人有任何想法在这里发生什么?
render() {
return (
<KeyboardAvoidingView style={{ flex: 1}} behavior="padding">
< View
style={{
flex: 1,
backgroundColor: "#FFFFFF",
}}
>
<ScrollView
contentContainerStyle={{ justifyContent: "flex-end", flex: 1 }}>
<ChatInfo />
</ScrollView>
<View style={styles.container}>
<TextInput
style={styles.input}
underlineColorAndroid="transparent"
autoCapitalize="none"
onChangeText={text => this.setState({ text: text })}
value={this.state.text}
/>
<TouchableOpacity
style={styles.submitButton}
onPress={this.submitName}
>
<Text style={styles.submitButtonText}> SEND </Text>
</TouchableOpacity>
</View>
</ View>
</KeyboardAvoidingView>
);
}
}
export default connect()(ChatScreen);
const styles = StyleSheet.create({
input: {
margin: 2,
paddingLeft: 15,
flex: 1,
height: …Run Code Online (Sandbox Code Playgroud) 我已经在Windows上设置了本地响应环境.但是当我运行命令时
react-native run-android
Run Code Online (Sandbox Code Playgroud)
我收到以下错误 -
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> Could not initialize class com.android.sdklib.repository.AndroidSdkHandler
Run Code Online (Sandbox Code Playgroud)
我该如何解决?