Updating useeffect
This commit is contained in:
8
App.js
8
App.js
@@ -109,7 +109,7 @@ const MainNavigation = () => {
|
|||||||
activeColor="#0d6efd"
|
activeColor="#0d6efd"
|
||||||
inactiveColor="#FFFFFF"
|
inactiveColor="#FFFFFF"
|
||||||
barStyle={{ backgroundColor: '#000000' }}
|
barStyle={{ backgroundColor: '#000000' }}
|
||||||
sceneContainerStyle={{paddingBottom: 0}}
|
sceneContainerStyle={{paddingBottom: 0, paddingTop: 15}}
|
||||||
>
|
>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="Feed"
|
name="Feed"
|
||||||
@@ -198,7 +198,11 @@ export default function App() {
|
|||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="MainNavigation"
|
name="MainNavigation"
|
||||||
component={MainNavigation}
|
component={MainNavigation}
|
||||||
options={{ headerShown: true }}
|
options={{
|
||||||
|
headerShown: true,
|
||||||
|
tabBarLabel: 'EMI Social',
|
||||||
|
header: ()=>{<></>},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="Profile"
|
name="Profile"
|
||||||
|
|||||||
@@ -5,11 +5,17 @@ import API from './../API.js';
|
|||||||
import LoginForm from './../components/Login.js';
|
import LoginForm from './../components/Login.js';
|
||||||
|
|
||||||
export default function App({navigation, route}) {
|
export default function App({navigation, route}) {
|
||||||
useEffect(async () => {
|
useEffect(()=>{
|
||||||
let r = await API.isLoggedIn();
|
getData = async () => {
|
||||||
if(r){
|
let r = await API.isLoggedIn();
|
||||||
await API.logout();
|
if(r){
|
||||||
navigation.navigate('Login')
|
await API.logout();
|
||||||
|
navigation.navigate('Login')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getData();
|
||||||
|
return ()=>{
|
||||||
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ const getProfilePosts = async (profileid) => {
|
|||||||
try {
|
try {
|
||||||
const value = await AsyncStorage.getItem('profile_' + profileid)
|
const value = await AsyncStorage.getItem('profile_' + profileid)
|
||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
console.log(JSON.parse(value))
|
|
||||||
return JSON.parse(value);
|
return JSON.parse(value);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
@@ -61,7 +60,7 @@ let Profile = ({ navigation, route }) => {
|
|||||||
return ()=>{
|
return ()=>{
|
||||||
subscribed = false;
|
subscribed = false;
|
||||||
}
|
}
|
||||||
}, [route.params]);
|
}, [route.params?.profileid]);
|
||||||
const renderPost = (({ item }) => {
|
const renderPost = (({ item }) => {
|
||||||
if (item.nonOrganicType)
|
if (item.nonOrganicType)
|
||||||
return (<></>);
|
return (<></>);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ let LoginForm = () => {
|
|||||||
onChangeText={text => setEmail(text)}
|
onChangeText={text => setEmail(text)}
|
||||||
defaultValue={email}
|
defaultValue={email}
|
||||||
placeholder="email"
|
placeholder="email"
|
||||||
|
label="email:"
|
||||||
autoCapitalize='none'
|
autoCapitalize='none'
|
||||||
autoComplete='email'
|
autoComplete='email'
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
@@ -45,6 +46,7 @@ let LoginForm = () => {
|
|||||||
defaultValue={password}
|
defaultValue={password}
|
||||||
placeholder="password"
|
placeholder="password"
|
||||||
textContentType="password"
|
textContentType="password"
|
||||||
|
label="password:"
|
||||||
secureTextEntry={true}
|
secureTextEntry={true}
|
||||||
autoCapitalize='none'
|
autoCapitalize='none'
|
||||||
autoComplete='email'
|
autoComplete='email'
|
||||||
@@ -68,7 +70,7 @@ const styles = StyleSheet.create({
|
|||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
justifyContent: "flex-start",
|
justifyContent: "center",
|
||||||
padding: 15,
|
padding: 15,
|
||||||
width: "100%",
|
width: "100%",
|
||||||
alignContent: 'center',
|
alignContent: 'center',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Text, ScrollView, FlatList, StyleSheet, View, Linking } from 'react-native';
|
import { Text, ScrollView, FlatList, StyleSheet, View } from 'react-native';
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
import Hyperlink from 'react-native-hyperlink'
|
||||||
import { Avatar, Button, Card, Title, Chip } from 'react-native-paper';
|
import { Button, Card, Chip } from 'react-native-paper';
|
||||||
import API from './../API.js';
|
import API from './../API.js';
|
||||||
import UserName from './UserName.js';
|
import UserName from './UserName.js';
|
||||||
import Media from './Media.js';
|
import Media from './Media.js';
|
||||||
@@ -62,7 +62,7 @@ let Post = (props) => {
|
|||||||
{!post.nonOrganicType ?
|
{!post.nonOrganicType ?
|
||||||
<View>
|
<View>
|
||||||
<Text style={styles.userName}>
|
<Text style={styles.userName}>
|
||||||
<UserName profileid={post.profileid} />
|
<UserName profileid={post.profileid}/>
|
||||||
{toProfileText}
|
{toProfileText}
|
||||||
<Text style={{ fontWeight: 'normal', fontSize: 12 }}>
|
<Text style={{ fontWeight: 'normal', fontSize: 12 }}>
|
||||||
{" " + Moment(post.createdAt).fromNow()}
|
{" " + Moment(post.createdAt).fromNow()}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ let UserName = ({ profileid, hideIcon }) => {
|
|||||||
let p = await API.getUserProfile(profileid).catch(() => { return {} });
|
let p = await API.getUserProfile(profileid).catch(() => { return {} });
|
||||||
if (subscribed)
|
if (subscribed)
|
||||||
setProfile(p);
|
setProfile(p);
|
||||||
storeName(profileid, p)
|
storeName(profileid, p);
|
||||||
|
console.log("Fetching Name:" + p?.profile?.firstName);
|
||||||
}
|
}
|
||||||
getData();
|
getData();
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user