Skip to content

Commit

Permalink
noweet 기능 구현 (트윗)
Browse files Browse the repository at this point in the history
(firebase - firestore)
  • Loading branch information
keynene committed Feb 6, 2023
1 parent 7d53a88 commit 70fea44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/fbase.js
Expand Up @@ -16,4 +16,5 @@ firebase.initializeApp(firebaseConfig);

export const firebaseInstance = firebase;

export const authService = firebase.auth();
export const authService = firebase.auth();
export const dbService = firebase.firestore();
12 changes: 11 additions & 1 deletion src/routes/Home.js
@@ -1,9 +1,19 @@
import { dbService } from 'fbase';
import React, { useState } from 'react';

const Home = () => {
const [noweet, setNoweet] = useState("");
const onSubmit = (e) => {
const onSubmit = async (e) => {
// submit 버튼 클릭하면 firebase의 collections에 데이터가 추가됨 (이거 이용해서 트윗 올리고 보여주고 하는듯)
e.preventDefault();
await dbService.collection("noweets").add({
//넣을 데이터
noweet,
createdAt: Date.now()
});
//데이터 올리고 noweet은 초기화 시켜주기
setNoweet("");

}
const onChange = (e) => {
// setNoweet(e.target.value) : 똑같이 동작하는데 왜 이렇게 안쓰지? value 말고 여러 값 저장하려면 es6 문법이 편해서 그런가
Expand Down

0 comments on commit 70fea44

Please sign in to comment.