Question
All this code is contained within the app.js but i need to separate it into homescreen.js,additionscreen.js,genrescreen.js,historyscreen.js . how would i do so ? and what
All this code is contained within the app.js but i need to separate it into homescreen.js,additionscreen.js,genrescreen.js,historyscreen.js . how would i do so ? and what code would i have to change?
import React, {useState} from 'react';
import { Text, TextInput, View,
Button,StyleSheet
,Flatlist,ImageBackground,
SafeAreaView,
FlatList,
ListItem,
Image,
TouchableOpacity,
}
from 'react-native';
import { NavigationContainer } from '@react-navigationative';
import { createNativeStackNavigator } from '@react-navigationative-stack';
import {Picker} from '@react-native-picker/picker';
import IconGenre from 'react-native-vector-icons/Entypo';
import IconPlus from 'react-native-vector-icons/AntDesign';
import IconHome from 'react-native-vector-icons/AntDesign';
import IconHistory from 'react-native-vector-icons/FontAwesome';
import Bookdatabase1 from './Data /Bookdatabase1.json';
import Bookdatabase2 from './Data /Bookdatabase2.json';
import Bookdatabase3 from './Data /Bookdatatbase3.json';
let totalBooks = 0;
function HomeScreen({ navigation, route }) {
const [totalPages, setTotalPages] = React.useState(0);
const [averagePages, setAveragePages] = React.useState(0);
const [title, setTitle] = React.useState('');
const [author, setAuthor] = React.useState('');
const [nPages, setnPages] = React.useState('');
const [num, setNum] = React.useState(0);
React.useEffect(() => {
if (route.params?.post) {
if(route.params.bookAdded){
totalBooks++;
}
setTitle(route.params?.post);
setAuthor(route.params?.post1);
setnPages(route.params?.post2);
setTotalPages(totalPages + parseInt(route.params?.post2));
setAveragePages(totalPages/totalBooks);
}
}, [route.params?.post]);
const a = parseInt(totalPages);
const b = parseInt(totalBooks);
let result = parseFloat( a / b)
return (
);
}
function AdditionScreen({ navigation, route }) {
const [title, setTitle] = React.useState('');
const [author, setAuthor] = React.useState('');
const [nPages, setnPages] = React.useState('');
const[selectedValue,setSelectedValue] = React.useState('');
return (
placeholder="Enter title" style={{ height: 50, padding: 10, backgroundColor: 'white' }} value={title} onChangeText={setTitle} /> placeholder="Enter author" style={{ height: 50, padding: 10, backgroundColor: 'white' }} value={author} onChangeText={setAuthor} /> placeholder="Enter Pager numbers" style={{ height: 50, padding: 10, backgroundColor: 'white' }} value={nPages} onChangeText={setnPages} />
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started