升级到0.26.0-rc版本后,此行:
React.findNodeHandle(this.refs.myRef)
Run Code Online (Sandbox Code Playgroud)
抛出此错误消息:
未处理的JS异常:_react2.default.findNodeHandle不是函数.
我用这个导入React:
import React from 'react';
Run Code Online (Sandbox Code Playgroud)
文档仍然说: "一如既往,要获取组件的本机节点句柄,可以使用React.findNodeHandle(组件)."
javascript ecmascript-6 react-native react-native-android react-native-ios
我试图在React Native for Android中使用水平ScrollView,其中起始位置位于滚动图像的中间而不是(0,0).
该scrollTo方法似乎在内部正确调用,componentDidMount但在应用程序中没有任何移动,它仍然显示为从左侧开始滚动.
由于这是Android,我没有访问contentOffset道具或我会直接设置,根据文档.这是代码:
'use strict';
var React = require('react-native');
var {
StyleSheet,
View,
Text,
ScrollView,
Component,
} = React;
var precomputeStyle = require('precomputeStyle');
class Carousel extends Component {
constructor(props, context) {
super(props, context);
//this.changeContent = this.changeContent.bind(this);
}
componentDidMount() {
this.myScroll.scrollTo(100);
console.log("called DidMount");
}
render() {
return (
<View style={{flex: 1}}>
<ScrollView ref={(ref) => this.myScroll = ref}
contentContainerStyle={styles.container}
horizontal={true}
pagingEnabled={true}
showsHorizontalScrollIndicator={false}
bounces={true}
onMomentumScrollEnd={this.onAnimationEnd}
>
{this.props.children}
</ScrollView>
</View>
);
}
onAnimationEnd(e) { …Run Code Online (Sandbox Code Playgroud) 我正在使用react-native框架来开发我的Android应用程序.我想使用react-native-material-design库来制作Toolbar更多功能.
我在当前目录中安装了这个库,我的项目在命令下面使用: -
E:\>npm i react-native-material-design -g --save
C:\Users\ch-e00925\AppData\Roaming\npm
`-- react-native-material-design@0.3.7
+-- react-native-material-design-styles@0.2.6 (git+https://github.com/react-n
ative-material-design/react-native-material-design-styles.git#bdc029c1a1c83ff563
d10868be38b8aed1e9989b)
`-- react-native-vector-icons@2.1.0
+-- lodash@4.17.4
`-- yargs@4.8.1
+-- cliui@3.2.0
| +-- strip-ansi@3.0.1
| | `-- ansi-regex@2.1.1
| `-- wrap-ansi@2.1.0
+-- decamelize@1.2.0
+-- get-caller-file@1.0.2
+-- lodash.assign@4.2.0
+-- os-locale@1.4.0
| `-- lcid@1.0.0
| `-- invert-kv@1.0.0
+-- read-pkg-up@1.0.1
| +-- find-up@1.1.2
| | +-- path-exists@2.1.0
| | `-- pinkie-promise@2.0.1
| | `-- pinkie@2.0.4
| `-- read-pkg@1.1.0
| +-- load-json-file@1.1.0
| | +-- …Run Code Online (Sandbox Code Playgroud) 我正在使用React Native构建一个Android应用程序.
如何强制a TextInput"unFocus",这意味着光标在文本字段内闪烁.有对功能isFocused()和onFocus(),但实际上,我怎么得到的文本字段放弃焦点.一旦我点击进入,你会认为它会自动完成,但事实并非如此.
import React, {Component} from 'react';
import { AppRegistry, Text, View, StyleSheet, TextInput, TouchableOpacity}
from 'react-native';
var SHA256 = require("crypto-js/sha256");
export default class LoginForm extends Component{
constructor(props){
super(props);
this.state = {
email: '',
password:''
};
}
tryLogin = () => {
if(this.state.email=="email123" && this.state.password == "password"){
console.log("password verified");
this.props.navigator.replace({
title: 'Dashboard'
});
}
console.log(this.state.email);
console.log(this.state.password);
console.log("Hash" + SHA256(this.state.password));
}
render(){
return(
<View style={styles.container}>
<TextInput
style={styles.input}
placeholder="Email address"
placeholderTextColor="white"
onChangeText={(email) => this.setState({email})}>
</TextInput> …Run Code Online (Sandbox Code Playgroud) 我想检查当设备后退按钮被击中时是否有多个屏幕在堆栈上.如果是,我想显示前一个屏幕,如果没有,我想退出应用程序.
我已经检查了一些示例,但是那些使用了BackAndroid和Navigator.但他们俩都被弃用了.BackHandler是BackAndroid的替代品.我可以使用props.navigation.goBack(null)显示上一个屏幕.
但是我无法找到用于在堆栈中查找屏幕计数的代码.我不想使用已弃用的Navigator!
navigation back-button back react-native react-native-android
在Android和iOS中分别在后台运行任务有不同的方法.我发现在android中安排任务的最佳方法是什么?以及堆栈溢出.
我想知道哪种是最好的方式react-native.使用setInterval或setTimeout必须每天或每隔几小时运行的任务是否足够好?
这些任务不会被操作系统杀死吗?
任何想法或建议?
我正在寻找一种在React-native中制作水平ListView或FlatList的方法.如下图所示:https://i.stack.imgur.com/D4RA5.jpg
我尝试使用Flex管理它,但这会让我产生奇怪的结果,并且总是使用垂直ListView
如果您有任何想法,请告诉我.
问候,
horizontal-scrolling react-native react-native-listview react-native-android react-native-ios
在Android设备上运行React Native时出现警告:
调试器和设备时间已超过60秒.请通过
adb shell "date `date +%m%d%H%M%Y.%S`"在调试器计算机上运行来更正此问题
但是当我按照上面的建议运行命令时,我得到并且操作不允许错误:
日期:无法设置日期:不允许操作
我已经尝试过sudo,仍然得到相同的结果:
sudo adb shell "date `date +%m%d%H%M%Y.%S`"
Run Code Online (Sandbox Code Playgroud) 我必须将我要显示的第一个字母大写.我搜索它但我找不到明确的事情,也没有这样的道具text反应本机官方文档.
我用以下格式显示我的文本:
<Text style={styles.title}>{item.item.title}</Text>
Run Code Online (Sandbox Code Playgroud)
要么
<Text style={styles.title}>{this.state.title}</Text>
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
建议欢迎?
react-native ×10
android ×2
adb ×1
back ×1
back-button ×1
ecmascript-6 ×1
focus ×1
javascript ×1
navigation ×1
scrollview ×1
text ×1
user-input ×1