Advertisement
armadiazrino

App.js

Nov 29th, 2020
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useEffect, useState } from "react"
  2. import { ScrollView, StatusBar, StyleSheet, View } from "react-native"
  3. import Header from "./component/Header"
  4. import PrayerScheduleCard from "./component/PrayerScheduleCard"
  5.  
  6. const App = () => {
  7.   const [shalatSchedule, setShalatSchedule] = useState(undefined)
  8.  
  9.   useEffect(() => {
  10.     fetchJadwalSholat()
  11.   }, [])
  12.  
  13.   const fetchJadwalSholat = async () => {
  14.     try {
  15.       const apiName =
  16.         "http://api.aladhan.com/v1/hijriCalendarByCity?city=Jakarta&country=Indonesia"
  17.       let response = await fetch(apiName)
  18.       let responseJson = await response.json()
  19.       if (responseJson) {
  20.         console.log("sholat timings ->", responseJson)
  21.       }
  22.     } catch (error) {
  23.       console.log("error ->", error)
  24.     }
  25.   }
  26.   return (
  27.     <ScrollView style={styles.mainContainer}>
  28.       <StatusBar backgroundColor={"rgb(239,81,83)"} />
  29.       <Header title={"Hello Rino!"} time={"15:31"} />
  30.       <View style={styles.prayerCardContainer}>
  31.         <PrayerScheduleCard location={"Bandung"} prayers={shalatSchedule} />
  32.       </View>
  33.     </ScrollView>
  34.   )
  35. }
  36.  
  37. const styles = StyleSheet.create({
  38.   mainContainer: {
  39.     backgroundColor: "rgb(255,248,222)",
  40.     flexGrow: 1,
  41.   },
  42.   prayerCardContainer: {
  43.     top: -48,
  44.   },
  45. })
  46. export default App
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement