From 6547c89f8138bc43a0ad0506945da56ea45c6591 Mon Sep 17 00:00:00 2001 From: isaacwsolomon <isaacwsolomon@gmail.com> Date: Sun, 11 May 2025 21:39:38 +0200 Subject: [PATCH] Connected to firebase database --- app/screens/list.tsx | 23 ++++++++++++++++------- firebaseConfig.ts | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/screens/list.tsx b/app/screens/list.tsx index 2c909ef..f22d13a 100644 --- a/app/screens/list.tsx +++ b/app/screens/list.tsx @@ -1,14 +1,23 @@ -import React from 'react'; +import { addDoc, collection } from 'firebase/firestore'; +import React, { useEffect } from 'react'; import { View, Text, Button } from 'react-native'; +import { FIRESTORE_DB } from '../../firebaseConfig'; const List = ({navigation} : any) => { - return ( - <View> - <Text>List</Text> - <Button onPress={() => navigation.navigate('Details')} title="Open Details"/> - </View> - ); +useEffect(() => {}, []); + +const addTodo = async () => { + console.log('ADD'); + + const doc = addDoc(collection(FIRESTORE_DB, 'todos'), { title: 'I am a test', done: false }); + console.log('📝 ~ file: List.tsx:12 ~ addTodo ~ doc:', doc); }; +return ( + <View> + <Button onPress={() => addTodo()} title="Add Todo" /> + </View> +); +} export default List; \ No newline at end of file diff --git a/firebaseConfig.ts b/firebaseConfig.ts index b89b522..806debb 100644 --- a/firebaseConfig.ts +++ b/firebaseConfig.ts @@ -22,4 +22,4 @@ const firebaseConfig = { export const FIREBASE_APP = initializeApp(firebaseConfig); export const FIRESTORE_DB = getFirestore(FIREBASE_APP); -export const FIREBASE_AUTH = getAuth(FIREBASE_APP); \ No newline at end of file +//export const FIREBASE_AUTH = getAuth(FIREBASE_APP); \ No newline at end of file -- GitLab