From f20e4f5cf1c93f5475dbb16429e73528d996cc8d Mon Sep 17 00:00:00 2001 From: Marcos Hernandez Date: Sat, 7 Oct 2023 11:46:07 -0700 Subject: [PATCH] deleted StoryScreen.tsx and moved file changes to story.tsx --- src/app/(tabs)/search/story.tsx | 35 +++++++++++++++++++++++++++-- src/screens/StoryScreen.tsx | 40 --------------------------------- 2 files changed, 33 insertions(+), 42 deletions(-) delete mode 100644 src/screens/StoryScreen.tsx diff --git a/src/app/(tabs)/search/story.tsx b/src/app/(tabs)/search/story.tsx index cd57613e..04df8cfd 100644 --- a/src/app/(tabs)/search/story.tsx +++ b/src/app/(tabs)/search/story.tsx @@ -1,11 +1,42 @@ -import { Text } from 'react-native'; +import { ActivityIndicator, ScrollView, Text, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; +import { useEffect, useState } from 'react'; +import HTMLView from 'react-native-htmlview'; import globalStyles from '../../../../globalStyles'; function StoryScreen() { + const [isLoading, setLoading] = useState(true); + const [title, setTitle] = useState(String); + const [content, setContent] = useState(String); + + const getStory = async (id: string) => { + try { + const url = `https://girlswritenow.org/wp-json/wp/v2/story/${id}`; + const response = await fetch(url); + const json = await response.json(); + setTitle(json.title.rendered); + setContent(json.content.rendered); + } catch (error) { + console.error(error); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + getStory('170947'); + }, []); + return ( - Story + {isLoading ? ( + + ) : ( + + + + + )} ); } diff --git a/src/screens/StoryScreen.tsx b/src/screens/StoryScreen.tsx deleted file mode 100644 index 96a8b9db..00000000 --- a/src/screens/StoryScreen.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { ActivityIndicator, ScrollView, View } from 'react-native'; -import HTMLView from 'react-native-htmlview'; - -export default function StoryScreen() { - const [isLoading, setLoading] = useState(true); - const [title, setTitle] = useState(String); - const [content, setContent] = useState(String); - - const getStory = async (id: string) => { - try { - const url = `https://girlswritenow.org/wp-json/wp/v2/story/${id}`; - const response = await fetch(url); - const json = await response.json(); - setTitle(json.title.rendered); - setContent(json.content.rendered); - } catch (error) { - console.error(error); - } finally { - setLoading(false); - } - }; - - useEffect(() => { - getStory('170947'); - }, []); - - return ( - - {isLoading ? ( - - ) : ( - - - - - )} - - ); -}