投稿時間:2022-06-19 18:13:22 RSSフィード2022-06-19 18:00 分まとめ(14件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita 東京海上日動プログラミングコンテスト2022(ABC256) A~D問題 ものすごく丁寧でわかりやすい解説 python 灰色~茶色コーダー向け #AtCoder https://qiita.com/sano192/items/d46b14a82b32b3bc9c1a atcoder 2022-06-19 17:14:21
AWS AWSタグが付けられた新着投稿 - Qiita Mac M1でビルドしたDockerイメージがEC2で起動できなかった https://qiita.com/h2m_kinoko/items/4c75dedbca9eaab0639e uestedimagesplatformlinux 2022-06-19 17:55:07
Docker dockerタグが付けられた新着投稿 - Qiita Mac M1でビルドしたDockerイメージがEC2で起動できなかった https://qiita.com/h2m_kinoko/items/4c75dedbca9eaab0639e uestedimagesplatformlinux 2022-06-19 17:55:07
Git Gitタグが付けられた新着投稿 - Qiita git pullとgit fetchの差異 https://qiita.com/Eugene0901/items/085135ad19e6f87b0f24 fetch 2022-06-19 17:00:33
Ruby Railsタグが付けられた新着投稿 - Qiita 特定の条件下で attribute のデフォルト値が書き変わってしまう問題と、その対策として Rails/AttributeDefaultBlockValue を少し紹介 https://qiita.com/kkitadate/items/cbfe6d78e8f94f282ab3 activemodelattributes 2022-06-19 17:27:29
海外TECH DEV Community How to create a blog website with React & firebase -> Series2 https://dev.to/evansifyke/how-to-create-a-blog-website-with-react-firebase-series2-3jdd How to create a blog website with React amp firebase gt SeriesHello dev community Welcome to this series where we are building blogging website with react and firebase In the last tutorial we prepared the environments and created the login and HomePageCheck it out here or Here tooIn this article we are going to complete out build Let s prepare the UI where the user will add an image and caption of the image Create CreatePost js file that will contain the following codes import React useState from react import useSelector from react redux import selectUser from features userSlice import db from utils firebase import firebase from firebase compat app const CreatePost gt const user useSelector selectUser const postTitle setPostTitle useState const imageURL setimageURL useState const handleSubmit e gt e preventDefault db collection posts add uid user uid message postTitle displayName user displayName image imageURL timestamp firebase firestore FieldValue serverTimestamp setPostTitle setimageURL return lt div className w full mx auto py px border bg white border gray rounded md gt lt form className mx auto gt lt input value postTitle onChange e gt setPostTitle e target value className rounded full w full border outline px py focus outline green type text placeholder Enter Post Caption gt lt input value imageURL onChange e gt setimageURL e target value className rounded full mt w full border outline px py focus outline green type text placeholder Enter Image Url gt lt button onClick handleSubmit className hidden type submit gt Hidden Submit lt button gt lt form gt lt div gt export default CreatePost Note Our image input is a string meaning that we will paste image url from the internet or any other source Enter values from the input field and press Enter Key and your data will be submitted to the firestore database When we check at our firebase firestore we shall find that a new collection called posts has been created Now we need to fetch that data from the db to our webpage To fetch our data we will make use of useEffect hook Let s create feed js file that will help us fetch and hold our data import React useState useEffect from react import db from utils firebase import Post from Post function Feed fetch posts and store them in an array const posts setPosts useState useEffect gt db collection posts orderBy timestamp desc onSnapshot snapshot gt setPosts snapshot docs map doc gt id doc id data doc data return lt div className feed gt posts map post gt lt Post key post id message post data message timestamp post data timestamp displayName post data displayName image post data image likes post data likes uid post data uid gt lt div gt export default Feed Note we have used the map function instead of forEach function to map all the posts from our firestore collection this is because map is the new thing in town Now we have fetched our data from firestore let s create post js file that will handle the post details and display on the web page import React from react function Post displayName image timestamp message return lt div className bg white border border gray py px mt mb rounded md gt lt div className flex items center justify between border b pb gt lt div className flex items center space x gt lt div className text center items center pt bg green text white rounded full w h gt displayName lt div gt lt div className gt lt h gt displayName lt h gt lt p className text xs text gray gt new Date timestamp toDate toUTCString lt p gt lt div gt lt div gt lt div gt lt div className mt gt lt p gt message lt p gt lt div gt lt div className mt gt lt img className w full h src image alt gt lt div gt lt div className mt flex justify between items center w full gt lt div className cursor pointer bg gray hover bg gray text green py px gt lt p gt Like lt p gt lt div gt lt div className cursor pointer bg gray hover bg gray text green py px gt lt p gt Comment lt p gt lt div gt lt div className cursor pointer bg gray hover bg gray text green py px gt lt p gt Share lt p gt lt div gt lt div gt lt div gt export default Post Note we are importing all the props from feed js file Now we are done from sending out post and fetching it from firestore Let s export our feed js file to our HomePage js fileimport React useEffect from react import useDispatch useSelector from react redux import login logout selectUser from features userSlice import auth from utils firebase import CreatePost from CreatePost import Feed from Feed import Header from Header const HomePage gt const user useSelector selectUser const dispatch useDispatch useEffect gt auth onAuthStateChanged userAuth gt if userAuth dispatch login email userAuth email uid userAuth uid displayName userAuth displayName else dispatch logout dispatch return lt gt lt Header gt lt div className flex space x justify between w mx auto mt gt lt div className hidden h bg white rounded md border border border gray pb md flex flex col items center w gt lt img className rounded t md h w full src ixid MnwxMjAfDBMHxzZWFyYhMxYkaWnfGVufDBfDBfA D D amp w amp q alt text gt lt div className text center items center pt mt bg green text white rounded full w h gt user displayName lt div gt lt p className mt gt user displayName lt p gt lt div gt lt div className mx auto w full gt lt CreatePost gt lt Feed gt lt div gt lt div className hidden bg white rounded md border border border gray pb md block py px w h gt lt h gt Trending topics lt h gt lt div className text left items center pt space y gt lt p className text sm text gray gt Javascript lt p gt lt p className text sm text gray gt Java lt p gt lt p className text sm text gray gt Typescript lt p gt lt p className text sm text gray gt Python lt p gt lt p className text sm text gray gt Data Science lt p gt lt p className text sm text gray gt Machine Learning lt p gt lt div gt lt div gt lt div gt lt gt export default HomePage Note we are using the home page to style our application so we can export our page to the App js file and handle the authentication to show the homepage if the user is not logged in Now let s import our HomePage js file to our App js file import React useEffect from react import Routes Route from react router dom import HomePage from components HomePage import App css import Login from components Login import useDispatch useSelector from react redux import login logout selectUser from features userSlice import auth from utils firebase function App const dispatch useDispatch const user useSelector selectUser validate and keep the user loggedIn useEffect gt auth onAuthStateChanged userAuth gt if userAuth dispatch login email userAuth email uid userAuth uid displayName userAuth displayName profilePic userAuth photoURL else dispatch logout dispatch return lt div className gt lt Routes gt user lt Route path element lt Login gt gt lt Route path element lt HomePage gt gt lt Routes gt lt div gt export default App In App js file we have made use of react router dom to handle our routes when the user is authenticated To install react router dom use the following commandnpm install react router dom ConclusionWe have finally created a complete blogging website with react and firebase In our final build on this series we are going to deploy it to firebase This article series was originally published at melbite com create blogging web with react firebaseYou can find more of my articles on To get the source code of this beautiful application check my github 2022-06-19 08:12:08
ニュース BBC News - Home Rail strikes will punish innocent people, transport secretary says https://www.bbc.co.uk/news/uk-61854567?at_medium=RSS&at_campaign=KARANGA blame 2022-06-19 08:38:57
ニュース BBC News - Home Manchester United chief executive Richard Arnold heads off protest as he meets fans in pub https://www.bbc.co.uk/sport/football/61856219?at_medium=RSS&at_campaign=KARANGA Manchester United chief executive Richard Arnold heads off protest as he meets fans in pubManchester United chief executive Richard Arnold headed off a planned protest outside his Cheshire house by meeting some fans in his local pub 2022-06-19 08:38:12
北海道 北海道新聞 東京で1622人感染 コロナ、4人死亡 https://www.hokkaido-np.co.jp/article/695442/ 新型コロナウイルス 2022-06-19 17:18:00
北海道 北海道新聞 西村が今季初、通算5勝目 ニチレイ・レディース最終日 https://www.hokkaido-np.co.jp/article/695429/ 千葉県袖ケ浦 2022-06-19 17:03:00
北海道 北海道新聞 室蘭港クレーン無償提供が正念場 市財政を圧迫、使用料徴収検討 https://www.hokkaido-np.co.jp/article/695312/ 無償提供 2022-06-19 17:17:39
北海道 北海道新聞 マイナカード普及、財政優遇 来年度から交付税見直し https://www.hokkaido-np.co.jp/article/695440/ 金子恭之 2022-06-19 17:13:00
北海道 北海道新聞 比例で自27%、維・立7% 物価高対策・経済重視42% https://www.hokkaido-np.co.jp/article/695439/ 共同通信社 2022-06-19 17:04:00
IT 週刊アスキー 辛い夏バーガー! ウェンディーズ・ファーストキッチンで「ハラペーニョポッパー」 https://weekly.ascii.jp/elem/000/004/095/4095029/ 夏季限定 2022-06-19 17:30:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)