我已经在 react native android 中构建了一个学习管理系统应用程序。我AsyncStorage用于简单的状态管理,而根本没有使用 redux。我现在面临的问题是,如果我要通过执行不同的操作来连续使用该应用程序操作然后应用程序变得非常慢。我认为这是内存泄漏,因为当我从后台杀死应用程序并再次打开它时,它没有任何延迟地工作。所以我不知道如何避免这种内存泄漏。我试过了许多解决方案
console.log从应用程序中删除了所有内容ComponentDidMount代替ComponentWillMount。但我不知道如何从堆内存中删除数据。数据是否存储在heap每个导航中?所以这会使应用程序的性能非常慢。不知道我说的对不对。如果我的概念有任何错误,redux请见谅。现在没有时间更改状态管理。请任何人帮助我找到解决方案,这将是一个很大的帮助。谢谢!
javascript memory-leaks memory-management reactjs react-native
如何在文本中将文本垂直放置在本机中?我找到了这个文档.但我不能这样做,我不能添加text标签作为标签的子组件.Image我尝试过如下.
<Card>
<CardSection>
<View style={styles.container}>
<Image source={require('../Images/4.jpg')} style={styles.imageStyl} />
<Text style={styles.userStyle}>
{this.props.cat.name}
</Text>
</View>
</CardSection>
</Card>
const styles= StyleSheet.create({
container:{
flex: 1,
alignItems: 'stretch',
justifyContent: 'center',
},
imageStyl: {
flexGrow:1,
width:"100%",
height:200,
alignItems: 'center',
justifyContent:'center',
},
userStyle:{
fontSize:18,
color:'black',
fontWeight:'bold',
textAlign: 'center'
},
});
Run Code Online (Sandbox Code Playgroud)
我使用react native创建了一个应用程序.我正在尝试在我的设备上安装该应用程序.但是显示此错误"app not installed -package似乎已损坏".
那是什么原因?我尝试了以下方法来构建apk.
gradlew assembleRelease.
将"unique Id"保存为react native中的会话变量
在我的React Native应用程序中,我正在获取包含原始html标签的json数据.如何从中删除html标签?以下是我得到的json响应
[{
"data": {
"course": {
"id": 2864,
"name": "2. Understanding India’s economic transition",
"date_created": 1506154480,
"status": "publish",
"price": false,
"price_html": "FREE",
"total_students": 0,
"seats": "",
"start_date": false,
"average_rating": 0,
"rating_count": 0,
"featured_image": "https://www.mywebsite.com/lms/wp-content/themes/wplms/assets/images/avatar.jpg",
"categories": [],
"instructor": {
"id": "22",
"name": "aami",
"avatar": "https://www.mywebsite.com/lms/wp-content/uploads/2017/11/favicon.png",
"sub": ""
},
"menu_order": 0
},
"description": "<p style=\"text-align: justify;\">India is undergoing an economic, social and technological transformation. Perhaps no other phase is going to be as critical as the present one in shaping the …Run Code Online (Sandbox Code Playgroud) 我如何在Asyncstorge中设置多个值?因为我正在尝试设置token和user_id。这些是服务器响应值。这就是响应的样子
json
{ error: 0,
data: 'User registered Successfully',
userData:
{ pwd: 'lmlmlm',
phone_no: '9898989',
user_name: '',
status: 1,
date: 2018-10-24T07:12:20.656Z },
user_id: 60,
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.' }
Run Code Online (Sandbox Code Playgroud)
在响应本机之后,我在用户注册后就这样写了。
.then((response) => response.json())
.then((responseData) =>
{
console.log(responseData);
AsyncStorage.setItem('id_token', responseData.token),
AsyncStorage.setItem('user_id', responseData.user_id),
Actions.firstScreen();
});
Run Code Online (Sandbox Code Playgroud)
而在我的主页,我访问token和user_id内AsyncStorage作为
AsyncStorage.getItem('id_token').then((usertoken) =>{
this.setState({'id_token' : usertoken});
console.log(usertoken);
})
AsyncStorage.getItem('user_id').then((uid) => {
this.setState({'user_id': uid});
console.log(uid);
})
Run Code Online (Sandbox Code Playgroud)
但是我只得到token的uid控制台结果变为null。但是当我进行控制台操作时,其中包含responseData值。请帮助我
我正在开始一个新的反应本机app.So什么是做UI的最佳方式?我试过一个ui-kit,但它似乎比从头开始构建更复杂.所以请指导我一个有效的方法.但我认为使用ui-kit构建应用程序不会花费太多时间吗?我很困惑请指导我.
在弹出对话框中,我想将按钮放置在同一行,但现在我得到这样的https://i.stack.imgur.com/sJ30p.png.Following是给定的样式。
<PopupDialog
ref={popupDialog => {
this.popupDialog = popupDialog;
}}
dialogStyle={{ backgroundColor: "#ddd", height: 200, width:320, border:10,padding:10}}
overlayBackgroundColor="#fff"
dismissOnTouchOutside={true}
>
<View style={styles.dialogContentView}>
<Text style={{fontSize:18}}>Are you sure you want to submit?</Text>
<View style={styles.button_1}>
<Button
title="Yes"
onPress={() => {
console.log('clicked')
}}
/>
</View>
<View style={styles.button_1}>
<Button
title="No"
onPress={() => {
console.log('clicked')
}}
/>
</View>
</View>
</PopupDialog>
.....
....
dialogContentView: {
flex: 1,
flexDirection: 'column',
justifyContent: 'space-between'
},
button_1:{
width: '40%',
height: 30,
Run Code Online (Sandbox Code Playgroud)
}
我想以这样的方式排列卡片,使其形成网格视图。我尝试了几个网格视图组件,但我无法导航到数据中的每个项目npm install react-native-super-grid。所以我想用CardSection我的网格视图制作网格视图但我不知道如何将其排列在每行 2 张卡片的行内。以下是我的 CardSection 代码
卡片部分
const CardSection = (props) =>{
return(
<View style={styles.containerStyle}>
{props.children}
</View>
);
};
const styles ={
containerStyle: {
padding: 10,
backgroundColor: 'white',
borderWidth:0,
marginBottom:10,
marginLeft:10,
marginRight:10,
borderColor:'#808080',
marginTop:50,
elevation: 10,
flexDirection:'row',
flexWrap:'wrap'
}
};
Run Code Online (Sandbox Code Playgroud)
我现在尝试的只是列出卡片如下
列表
<CardSection>
<TouchableOpacity onPress={() => Actions.newworkRequest()}>
<Text>New Work Request</Text>
</TouchableOpacity>
</CardSection>
<CardSection>
<TouchableOpacity onPress={() => Actions.workerDetails()}>
<Text>Worker</Text>
</TouchableOpacity>
</CardSection>
<CardSection>
<TouchableOpacity onPress={() => Actions.reportViewing()}>
<Text> Reports</Text>
</TouchableOpacity>
</CardSection>
<CardSection>
<TouchableOpacity onPress={() => Actions.compltpage()}>
<Text> …Run Code Online (Sandbox Code Playgroud) 我正在尝试在react native中设置背景图像。我想要背景封面图像。我已经完成了如下
<ScrollView>
<View>
<Image source={ require('../Images/5.jpg') } style = { styles.image } />
{
this.state.details.map(a =>
<View>
<Text style={ styles.textStyle } > { a.content = a.content.replace(regex, '') } < /Text>
< RadioForm style= {{ width: 350 - 30 }} outerColor = "#080103" innerColor = "#FF5733" itemShowKey = "label" itemRealKey = "item" dataSource = { transform(a.options) } onPress = {(item)=>this._onSelect(item)}/>
</View>)
}
</View>
</ScrollView>
const styles = StyleSheet.create({
image: {
flex: 1,
resizeMode: 'cover',
position: 'absolute',
width: "100%",
flexDirection: 'column' …Run Code Online (Sandbox Code Playgroud) 我想以不同的背景颜色显示侧边栏内容。为此,我已经尝试过TouchableOpacity underlay。但这不是我要找的那个。给出后TouchableOpacity,它只会改变文本的颜色,而不是整个列表背景。我如何在使用原生基本 ui 套件时更改列表项背景颜色。请帮助。有什么方法可以做到这一点?侧边栏是这样的。我做了类似以下的事情。在里面设置pressStatus为 trueonPresList如果是真的改变背景颜色。但是导航到route不起作用。有一个错误
https://i.stack.imgur.com/w9YiR.png
如何更改 onPress 的背景颜色?以下是我的代码。
更新
import React, { Component } from "react";
import { Image, FlatList } from "react-native";
import {
Content,
Text,
List,
ListItem,
Icon,
Container,
Left,
Right,
Badge,
Thumbnail
} from "native-base";
import styles from "./style";
const drawerCover = require("../../imgs/quwait.jpg");
const datas = [
{
name: "Dashboard",
route: "Anatomy",
icon: require("../../imgs/dashboard.png"),
},
{
name: "Companies",
route: "Header",
icon: require("../../imgs/enterprise1.png"),
},
{
name: "Company …Run Code Online (Sandbox Code Playgroud)react-native ×11
javascript ×7
jsx ×6
reactjs ×4
asyncstorage ×2
json ×2
android ×1
apk ×1
gridview ×1
html ×1
image ×1
memory-leaks ×1
native-base ×1
react-redux ×1
session ×1