Valtio and new tab menu
This commit is contained in:
@@ -4,6 +4,8 @@ import { ScrollView, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } fro
|
||||
import { Title } from 'react-native-paper';
|
||||
import API from "../API";
|
||||
import CourseCard from "../components/CourseCard";
|
||||
import { useSnapshot } from 'valtio';
|
||||
import GlobalState from '../contexts/GlobalState.js';
|
||||
|
||||
|
||||
const getCourses = async (profileObj) => {
|
||||
@@ -48,7 +50,8 @@ const getCourses = async (profileObj) => {
|
||||
}
|
||||
|
||||
const Courses = () => {
|
||||
const [Me, setMeProfile] = React.useState({});
|
||||
const gState = useSnapshot(GlobalState);
|
||||
const viewer = gState.me;
|
||||
const [searchQuery, setSearchQuery] = React.useState('');
|
||||
const [groups, setGroups] = React.useState([]);
|
||||
const [popular, setPopular] = React.useState([]);
|
||||
@@ -56,12 +59,7 @@ const Courses = () => {
|
||||
const [queryTimer, setQueryTimer] = React.useState(0);
|
||||
|
||||
useEffect(async () => {
|
||||
let Me = await API.getMe();
|
||||
setMeProfile(Me);
|
||||
//API.getCourses('').then((data) => {
|
||||
// setGroups(data.groups || []);
|
||||
//});
|
||||
let r = await getCourses(Me);
|
||||
let r = await getCourses(viewer);
|
||||
setGroups(r.courses || []);
|
||||
setPopular(r.popular || []);
|
||||
setWatching(r.watching || []);
|
||||
|
||||
Reference in New Issue
Block a user