Skip to content

Commit

Permalink
deleted StoryScreen.tsx and moved file changes to story.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Hernandez committed Oct 7, 2023
1 parent c2944c1 commit f20e4f5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 42 deletions.
35 changes: 33 additions & 2 deletions src/app/(tabs)/search/story.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<SafeAreaView style={globalStyles.container}>
<Text style={globalStyles.h1}>Story</Text>
{isLoading ? (
<ActivityIndicator />
) : (
<ScrollView>
<HTMLView value={title} />
<HTMLView value={content} />
</ScrollView>
)}
</SafeAreaView>
);
}
Expand Down
40 changes: 0 additions & 40 deletions src/screens/StoryScreen.tsx

This file was deleted.

0 comments on commit f20e4f5

Please sign in to comment.