<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Caffeine Code</title>
    <description>The latest articles on DEV Community by Caffeine Code (@caffeinecode).</description>
    <link>https://dev.to/caffeinecode</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F806145%2Fb69ed2df-bb84-4d68-b776-c5a35f2ea5c6.png</url>
      <title>DEV Community: Caffeine Code</title>
      <link>https://dev.to/caffeinecode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/caffeinecode"/>
    <language>en</language>
    <item>
      <title>How to Host Your React App for Free and Reach Millions of Users: Top 4 Platforms Revealed!</title>
      <dc:creator>Caffeine Code</dc:creator>
      <pubDate>Wed, 22 Jun 2022 17:18:26 +0000</pubDate>
      <link>https://dev.to/caffeinecode/best-free-hosting-services-k08</link>
      <guid>https://dev.to/caffeinecode/best-free-hosting-services-k08</guid>
      <description>&lt;p&gt;Choosing A Web hosting A very tough decision. because Your Whole website's performance depends on it.&lt;/p&gt;

&lt;p&gt;A website’s usability lies on three pillars – a good web design, search engine optimisation and a solid web hosting.&lt;/p&gt;

&lt;p&gt;You need to have a good web hosting account or hire a web hosting company that will ensure that your website is visible to people on the internet.&lt;/p&gt;

&lt;p&gt;The web host provides the space for you to store your website on the internet.&lt;br&gt;
When users type your domain name on their web browser, their computer connects to the server your website is hosted on. Then that server sends the files that are up for display, to the user on their browser.&lt;/p&gt;

&lt;p&gt;There are primarily two kinds of web hosting solutions. One is free service &lt;br&gt;
and the other is premium paid service.&lt;/p&gt;

&lt;p&gt;Q. Can I host my website for free? and It is Good to choose a free hosting ?&lt;br&gt;
So my answer is simple.&lt;br&gt;
Yes, you can. There several website which offers free hosting plans. After you can purchase their premium plan also. &lt;br&gt;
For hobby projects or any other small websites, Free hosting is very good option. But if you want to Start a business through website than you will need a website definitely.&lt;/p&gt;

&lt;p&gt;There are several free hosting platforms that support React applications. Here are some of the best ones:&lt;br&gt;
GitHub Pages: GitHub Pages is a popular platform that allows you to host static websites and web apps. It offers a simple way to host your React app, and it's free. You can easily deploy your app to GitHub Pages by creating a repository, configuring your settings, and pushing your code to the repository.&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=kLBYwmNLGVM&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=1"&gt;https://www.youtube.com/watch?v=kLBYwmNLGVM&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Netlify: Netlify is another popular hosting platform for static websites and web apps. It offers a free tier that allows you to host your app with a custom domain, continuous deployment, and other features. Netlify is easy to use and provides a great developer experience.&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=CxQ8qAK3xGg&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=2"&gt;https://www.youtube.com/watch?v=CxQ8qAK3xGg&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vercel: Vercel is a cloud platform that offers hosting, deployment, and other features for building web applications. It's free to use, and it includes custom domains, SSL encryption, and other features.&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=Sjf3u52eeIM&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=6&amp;amp;t=44s&amp;amp;ab_channel=CaffeineCode"&gt;https://www.youtube.com/watch?v=Sjf3u52eeIM&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=6&amp;amp;t=44s&amp;amp;ab_channel=CaffeineCode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Firebase Hosting: Firebase Hosting is a hosting platform that's part of the Firebase suite of products. It's a great choice for hosting your React app, as it offers a free tier that includes hosting, SSL encryption, and a global CDN. Firebase Hosting is easy to use and integrates well with other Firebase services.&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=bTQoOwkuLlM&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=4&amp;amp;t=22s&amp;amp;ab_channel=CaffeineCode"&gt;https://www.youtube.com/watch?v=bTQoOwkuLlM&amp;amp;list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&amp;amp;index=4&amp;amp;t=22s&amp;amp;ab_channel=CaffeineCode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All of these platforms offer great features for hosting React apps for free. You can choose the one that suits your needs best.&lt;br&gt;
If you excited to know How to Host Your React App on these platforms, you can check out my youtube playlist.&lt;br&gt;
&lt;a href="https://www.youtube.com/playlist?list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i"&gt;https://www.youtube.com/playlist?list=PLoyowRR99K8-Otyu_o_FoFpQ09RA_Fx8i&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>devops</category>
    </item>
    <item>
      <title>Google Chrome Extensions Can be Used to Track You Online</title>
      <dc:creator>Caffeine Code</dc:creator>
      <pubDate>Mon, 20 Jun 2022 08:23:26 +0000</pubDate>
      <link>https://dev.to/caffeinecode/google-chrome-extensions-can-be-used-to-track-you-online-4pkm</link>
      <guid>https://dev.to/caffeinecode/google-chrome-extensions-can-be-used-to-track-you-online-4pkm</guid>
      <description>&lt;p&gt;Hello guys, namaste ! Good morning !&lt;br&gt;
I am Vipin Bansal and welcome to the caffeine code. &lt;/p&gt;

&lt;p&gt;whenever you install a browser extension on google chrome.it can be used to construct fingerprints. these fingerprints stores information of your device. which is called tracking hashes.&lt;br&gt;
these hashes are used to track user's web activity.&lt;br&gt;
to proof that concept a web developer compay Z0CCC develops a website, where you can see all installed extensions in your device.&lt;/p&gt;

&lt;p&gt;this is link of that website.&lt;br&gt;
&lt;a href="https://z0ccc.github.io/extension-fingerprints/"&gt;https://z0ccc.github.io/extension-fingerprints/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/6ucd4LnWcXE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>chrome</category>
      <category>extension</category>
      <category>track</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to use YouTube API in React</title>
      <dc:creator>Caffeine Code</dc:creator>
      <pubDate>Thu, 02 Jun 2022 16:26:51 +0000</pubDate>
      <link>https://dev.to/caffeinecode/how-to-use-youtube-api-in-react-5hii</link>
      <guid>https://dev.to/caffeinecode/how-to-use-youtube-api-in-react-5hii</guid>
      <description>&lt;p&gt;Hello guys, namaste ! Good morning ! I am Vipin Bansal and welcome to the caffeine code.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/XWePdlCGTno"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;so in this post i am gonna show you , how can you use Youtube api in your react js application and show all videos and playlist.&lt;/p&gt;

&lt;p&gt;so first step is to create a new react app. i think you already familiar with create react app &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx create-react-app ytclone



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;and now, create a new file in &lt;code&gt;src&lt;/code&gt; folder. and name it &lt;code&gt;ytvideos.js&lt;/code&gt; because we use this file to show youtube videos. and create YTvideos function inside this file&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import react from "react";

export const YTvideos=()=&amp;gt;{
    return(
        &amp;lt;div&amp;gt;
            welcome
        &amp;lt;/div&amp;gt;
    );
};


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;so after creating this file, we will import &lt;code&gt;YTvideos&lt;/code&gt; function in our &lt;code&gt;app.js&lt;/code&gt; file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import { YTvideos } from "./ytvideos";

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;YTvideos/&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, we will goto youtube and select any video. and click on share button. and a window will popup , where you have to select &lt;code&gt;Embed link&lt;/code&gt; option. and then copy Iframe code.&lt;br&gt;
You can follow these images.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke4s0vky81wyy347aqii.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke4s0vky81wyy347aqii.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fobdm9n6e3ysc97ax5eu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fobdm9n6e3ysc97ax5eu9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvik86flvoh3wkhl6mcqv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvik86flvoh3wkhl6mcqv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we had copied &lt;code&gt;iframe code&lt;/code&gt; of this videos.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;iframe width="560" height="315"
 src="https://www.youtube.com/embed/XWePdlCGTno" 
title="YouTube video player" frameborder="0" 
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" 
allowfullscreen&amp;gt;&amp;lt;/iframe&amp;gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now , we will copy it to our &lt;code&gt;ytvideos.js&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7f4olisfc096levcvtqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7f4olisfc096levcvtqr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so if you run &lt;code&gt;npm start&lt;/code&gt; at that moment , you will see this as result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxccvey6qai4tkxhtl95s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxccvey6qai4tkxhtl95s.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we forwards for the next step. that is Youtube APi.&lt;br&gt;
For that go on google and search youtube api. and click on first link you see. &lt;br&gt;
&lt;a href="https://developers.google.com/youtube/v3" rel="noopener noreferrer"&gt;https://developers.google.com/youtube/v3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;after going to that url. you will see Youtube Data API window , here you have two options &lt;code&gt;Add YouTube functionality to your site&lt;/code&gt; and second &lt;code&gt;Search for content&lt;/code&gt;. You should choose first. after choosing first , Youtube data api overview page will opens.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjetv9d1ti6ve5je4bic.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjetv9d1ti6ve5je4bic.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcf47msxqmvc2kual7o8u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcf47msxqmvc2kual7o8u.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and here you can see Introduction and instructions of youtube api before starting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp301ng9a12aate0rp0wu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp301ng9a12aate0rp0wu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now , click on the 2nd instuction blue text url. which will forward you to &lt;code&gt;Google Developers Console&lt;/code&gt;.&lt;br&gt;
So here you will see a dashboard , and button which is named &lt;code&gt;Enable APi and services&lt;/code&gt;. After clicking on that , a search box will appear. now search &lt;code&gt;youtube api&lt;/code&gt; in that search box.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F179a2vc589gjnja8jovk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F179a2vc589gjnja8jovk.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>api</category>
      <category>webdev</category>
      <category>youtubeapi</category>
    </item>
    <item>
      <title>How to add RichText Editor to React Blog Website</title>
      <dc:creator>Caffeine Code</dc:creator>
      <pubDate>Sun, 13 Feb 2022 11:25:24 +0000</pubDate>
      <link>https://dev.to/caffeinecode/how-to-add-tinymce-to-reactjs-blog-website-22jd</link>
      <guid>https://dev.to/caffeinecode/how-to-add-tinymce-to-reactjs-blog-website-22jd</guid>
      <description>&lt;p&gt;Hello guys, namaste !&lt;br&gt;
Today we are going to see how to implement TinyMCE Editor in our react app. Tinymce is a RichText Editor based on JavaScript library. &lt;br&gt;
Tinymce is fast and reliable way to integrate it with your existing codebase.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/gyvAdrArqgs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In this article , we start with a simple integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a simple React project
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Use the Create React App package to create a new React project named tinymce-react-demo.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx create-react-app@5.0.0 tinymce-react-demo


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Change to the newly created directory.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

cd tinymce-react-demo


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Test the application using the Node.js development server.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm run start


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Installing the TinyMCE React component
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Install the tinymce-react package and save it to your package.json with --save.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm install --save @tinymce/tinymce-react


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Adding the Editor component to our project
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open Our Blog Creation Form. (following create.js file created in previous part.) You can simply copy it from here.
&lt;code&gt;create.js&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React , {useState} from "react";
import fb from "./firebase";
const DB =fb.firestore()
const Blogslist = DB.collection('blogs');

const CreateBlog = () =&amp;gt; {

    const[title, SetTitle] = useState("");
    const[body, SetBody] = useState("");

    const submit =(e)=&amp;gt; {
        e.preventDefault();
        Blogslist.add ({
            Title: title,
            Body: body
        }).then((docRef)=&amp;gt; {
            alert("data successfully submit")
        }).catch((error) =&amp;gt; {
            console.error("error:", error);
        });
    }
    return(
        &amp;lt;div&amp;gt;
            &amp;lt;form onSubmit={(event) =&amp;gt; {submit(event)}}&amp;gt;    
            &amp;lt;input type="text" placeholder="Title" 
            onChange={(e)=&amp;gt;{SetTitle(e.target.value)}} required /&amp;gt;

            &amp;lt;textarea  name="content" type="text" placeholder="write your content here" 
            rows="10" cols="150" onChange={(e)=&amp;gt;{SetBody(e.target.value)}} required &amp;gt;
            &amp;lt;/textarea&amp;gt;

            &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
        &amp;lt;/form&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

export default CreateBlog;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Now import Editor component in &lt;code&gt;create.js&lt;/code&gt;from TinyMCE React library which we install.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import { Editor } from '@tinymce/tinymce-react';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Now Replace the textarea field through Editor component.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Before Replace&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;form onSubmit={(event) =&amp;gt; {submit(event)}}&amp;gt;    
    &amp;lt;input type="text" placeholder="Title" 
    onChange={(e)=&amp;gt;{SetTitle(e.target.value)}} required /&amp;gt;

    &amp;lt;textarea  name="content" type="text" placeholder="write your content here" 
    rows="10" cols="150" onChange={(e)=&amp;gt;{SetBody(e.target.value)}} required &amp;gt;
    &amp;lt;/textarea&amp;gt;

    &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;After Replace&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;form onSubmit={(event) =&amp;gt; {submit(event)}}&amp;gt;    
    &amp;lt;input type="text" placeholder="Title" 
    onChange={(e)=&amp;gt;{SetTitle(e.target.value)}} required /&amp;gt;

    &amp;lt;Editor
        textareaName='Body'
        initialValue="&amp;lt;p&amp;gt;This is the initial content of the editor.&amp;lt;/p&amp;gt;"
        init={{
            height: 500,
            menubar: false,
            plugins: [
                'advlist autolink lists link image charmap print preview anchor',
                'searchreplace visualblocks code fullscreen',
                'insertdatetime media table paste code help wordcount'
            ],
            toolbar: 'undo redo | formatselect | ' +
            'bold italic backcolor | alignleft aligncenter ' +
            'alignright alignjustify | bullist numlist outdent indent | ' +
            'removeformat | help',
            content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
        }}
        onEditorChange={(newText) =&amp;gt; SetBody(newText)}
    /&amp;gt;

    &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;In Editor component we use somenew attr inside of textarea attr.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;name -&amp;gt; textareaName&lt;br&gt;
placeholder -&amp;gt; initialValue&lt;br&gt;
onChange -&amp;gt; onEditorChange&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now Our &lt;code&gt;Create.js&lt;/code&gt; file look like following.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import { Editor } from '@tinymce/tinymce-react';
import react, {useState} from 'react';
import fb from './firebase';
const db = fb.firestore()
const Blogs = db.collection('blogs');

const CreateBlog= () =&amp;gt; {
    const [title , SetTitle] = useState("");
    const [body , SetBody] = useState("");

    const sub = (e) =&amp;gt; {
        e.preventDefault();
        // Add data to the store
        Blogs.add({
            Title: title,
            Body: body,
            publish: false,
            published_on: fb.firestore.Timestamp.fromDate(new Date())
        })
        .then((docRef) =&amp;gt; {
            alert("Data Successfully Submitted");
        })
        .catch((error) =&amp;gt; {
            console.error("Error adding document: ", error);
        });
    }
    return (
    &amp;lt;div&amp;gt;
        &amp;lt;form onSubmit={(event) =&amp;gt; {sub(event)}}&amp;gt;  
        &amp;lt;input type="text" placeholder="Title" 
            onChange={(e)=&amp;gt;{SetTitle(e.target.value)}} required /&amp;gt;
        &amp;lt;Editor
            textareaName='description'
            initialValue="&amp;lt;p&amp;gt;This is the initial content of the editor.&amp;lt;/p&amp;gt;"
            init={{
                height: 500,
                menubar: false,
                plugins: [
                  'advlist autolink lists link image charmap print preview anchor',
                  'searchreplace visualblocks code fullscreen',
                  'insertdatetime media table paste code help wordcount'
                ],
                toolbar: 'undo redo | formatselect | ' +
                'bold italic backcolor | alignleft aligncenter ' +
                'alignright alignjustify | bullist numlist outdent indent | ' +
                'removeformat | help',
                content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
              }}
            onEditorChange={(newText) =&amp;gt; SetBody(newText)}
        /&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
        &amp;lt;/form&amp;gt;

    &amp;lt;/div&amp;gt;

    );
}

export default CreateBlog;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Result&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnfkbowkyqhvmp5c5i23.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnfkbowkyqhvmp5c5i23.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Show RichText in Templates
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;open our Show.js file. (following show.js file created in previous part.) You can simply copy it from here.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Show.js&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React , {useState} from "react";
import { useParams} from 'react-router-dom';
import fb from "./firebase";
const DB =fb.firestore()
const Blogslist = DB.collection('blogs');

const BlogView = ()=&amp;gt; {
    const {id} = useParams();
    const[blogs, Setblogs] = useState([]);
    Blogslist.doc(id).get().then((snapshot) =&amp;gt; {
        const data = snapshot.data()
        Setblogs(data);
    });
    return(
        &amp;lt;div&amp;gt;
            &amp;lt;p&amp;gt;Title : { blogs.Title}&amp;lt;/p&amp;gt;
            &amp;lt;p&amp;gt;Body : { blogs.Body}&amp;lt;/p&amp;gt;

        &amp;lt;/div&amp;gt;
    );
};
export default BlogView;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;result&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcu04y4hbdzwmcqaetxd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcu04y4hbdzwmcqaetxd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now you can see our text is show in HTML format and we want to simply rendor our text in Non-HTML format. so will use  &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt; attr.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

const body = blogs.Body;
&amp;lt;div  dangerouslySetInnerHTML={{__html: body}} /&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Now Our file look like following.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React , {useState} from "react";
import { useParams} from 'react-router-dom';
import fb from "./firebase";
const DB =fb.firestore()
const Blogslist = DB.collection('blogs');

const BlogView = ()=&amp;gt; {
    const {id} = useParams();
    const[blogs, Setblogs] = useState([]);
    Blogslist.doc(id).get().then((snapshot) =&amp;gt; {
        const data = snapshot.data()
        Setblogs(data);
    });
    const body = blogs.Body;
    return(
        &amp;lt;div&amp;gt;
            &amp;lt;p&amp;gt;Title : { blogs.Title}&amp;lt;/p&amp;gt;
            &amp;lt;div  dangerouslySetInnerHTML={{__html: body}} /&amp;gt;

        &amp;lt;/div&amp;gt;
    );
};
export default BlogView;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;result&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2k6d6t696y978qt7238.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2k6d6t696y978qt7238.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is it, &lt;br&gt;
I hope you find this article useful. &lt;br&gt;
Thanks for reading!&lt;/p&gt;

</description>
      <category>react</category>
      <category>tinymce</category>
      <category>richtexteditor</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Build A Blog Website Using ReactJS and Firebase</title>
      <dc:creator>Caffeine Code</dc:creator>
      <pubDate>Mon, 31 Jan 2022 07:27:33 +0000</pubDate>
      <link>https://dev.to/caffeinecode/build-a-blog-website-using-reactjs-and-firebase-2mn1</link>
      <guid>https://dev.to/caffeinecode/build-a-blog-website-using-reactjs-and-firebase-2mn1</guid>
      <description>&lt;p&gt;Welcome buddy ! This blog post will teach you how to build a blog site using React and Firebase.&lt;br&gt;
First we will learn , Initial setup of Firebase.&lt;br&gt;
and then we connect our project to firebase.&lt;br&gt;
and third we will code our project.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/GERuklicI8k"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;so lets start First section&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Setup of Firebase
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to firebase website and signup. and than go on to the firebase console and create new project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvf6dc0spk6tvmiuymybp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvf6dc0spk6tvmiuymybp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsx4xrf8gey31yy35juok.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsx4xrf8gey31yy35juok.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now Enter the project name , and click on continue. it will lead you to next screen.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dy8prqlek9j4ki2jj0l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dy8prqlek9j4ki2jj0l.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;click on continue and you will land on second screen where you can select analytics account if opted for google analytics on the previous screen and click continue.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv0ohbswru6d8d60425rx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv0ohbswru6d8d60425rx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9vigv8360n9sc7210us.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9vigv8360n9sc7210us.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your Firebase Project is ready. Now go to project setting to connect React Project to Firebase.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwzx0ptz6vsnvbe1h45c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwzx0ptz6vsnvbe1h45c.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fei8ielkio2lh1pxuu0ay.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fei8ielkio2lh1pxuu0ay.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Build React app
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to your terminal and Create New React App using &lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx create-react-app@5.0.0 Blog-React-app
cd Blog-React-app
npm start


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Our react app is ready now we have to connect it to our firebase project. So first thing is to install firebase node modules in our project. you can run the following command to install the latest SDK:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm install firebase


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;now lets create a file structure for blog website.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxxg37v171flmywibxp3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxxg37v171flmywibxp3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;so first we create a &lt;code&gt;firebase.js&lt;/code&gt; file in &lt;code&gt;src&lt;/code&gt; folder. And copy Firebase configurations.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

firebase.initializeApp({
    apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    authDomain: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
    projectId: "xxxxxxxxxxxxxxx",
    storageBucket: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
    messagingSenderId: "xxxxxxxxx",
    appId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    measurementId: "xxxxx"
});

const fb = firebase;

export default fb;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Here, you can see i removed my project configurations. that is unique for every firbase project. So you have to go on your project setting and copy it and paste here.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frdfq002iw9tenqh0jkye.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frdfq002iw9tenqh0jkye.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now open &lt;code&gt;App.js&lt;/code&gt; file and remove all extra lines of code&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React from "react";


function App() {
  return (

  );
}

export default App;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Our Blogging website meanily works on four operations.&lt;code&gt;1.Create Blog&lt;/code&gt;&lt;code&gt;2. Show Blogs List&lt;/code&gt; &lt;code&gt;3. Read A Blog&lt;/code&gt; &lt;code&gt;4. Edit A Blog&lt;/code&gt; and last &lt;code&gt;5. Delete a Blog&lt;/code&gt;
so lets create a Create.js file in blogs directory in Src directory.
&lt;code&gt;src/components/blogs/create.js&lt;/code&gt;
first, we have to import database to our file. we will do that by this code.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import fb from '../firebase';
 db = fb.firestore()
const Blogs = db.collection('blogs');


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;hire, Fb is the module which we initialize in firebase.js file. and fb.firestore() points to our database on firebase.&lt;br&gt;
and the collection is a table of data. in which table you want to add new data.&lt;br&gt;
and in firebase you don't have to create table, you can directly insert data and firebase automatically creates a new collection.&lt;br&gt;
now, we will create a function to render our creation form. and take input from user to send it to database.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import {useState} from 'react';

const CreateBlog= () =&amp;gt; {
    const [title , SetTitle] = useState("");
    const [body , SetBody] = useState("");

    const sub = (e) =&amp;gt; {
        e.preventDefault();
        // Add data to the store
        Blogs.add({
            Title: title,
            Body: body,
            publish: false,
            published_on: fb.firestore.Timestamp.fromDate(new Date())
        })
        .then((docRef) =&amp;gt; {
            alert("Data Successfully Submitted");
        })
        .catch((error) =&amp;gt; {
            console.error("Error adding document: ", error);
        });
    }
    return (
    &amp;lt;div&amp;gt;

    &amp;lt;/div&amp;gt;

    );
}

export default CreateBlog;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;here We have created two variables which are &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;body&lt;/code&gt;. and intialize there value with black string. and when user click on submit button we will run a new function , which is named &lt;code&gt;sub = (e) =&amp;gt; {}&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;div&amp;gt;
        &amp;lt;form onSubmit={(event) =&amp;gt; {sub(event)}}&amp;gt;    
            &amp;lt;input type="text" placeholder="Title" 
            onChange={(e)=&amp;gt;{SetTitle(e.target.value)}} required /&amp;gt;

            &amp;lt;textarea  name="content" type="text" placeholder="write yoyr content here" 
            rows="10" cols="150" onChange={(e)=&amp;gt;{SetBody(e.target.value)}} required &amp;gt;
            &amp;lt;/textarea&amp;gt;

            &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
        &amp;lt;/form&amp;gt;
    &amp;lt;/div&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;so our complete file will look like this.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import {useState} from 'react';
import fb from '../firebase';
 db = fb.firestore()
const Blogs = db.collection('blogs');

const CreateBlog= () =&amp;gt; {
    const [title , SetTitle] = useState("");
    const [body , SetBody] = useState("");

    const sub = (e) =&amp;gt; {
        e.preventDefault();
        // Add data to the store
        Blogs.add({
            Title: title,
            Body: body,
            publish: false,
            published_on: fb.firestore.Timestamp.fromDate(new Date())
        })
        .then((docRef) =&amp;gt; {
            alert("Data Successfully Submitted");
        })
        .catch((error) =&amp;gt; {
            console.error("Error adding document: ", error);
        });
    }
    return (
    &amp;lt;div&amp;gt;
        &amp;lt;form onSubmit={(event) =&amp;gt; {sub(event)}}&amp;gt;    
            &amp;lt;input type="text" placeholder="Title" 
            onChange={(e)=&amp;gt;{SetTitle(e.target.value)}} required /&amp;gt;

            &amp;lt;textarea  name="content" type="text" placeholder="write yoyr content here" 
            rows="10" cols="150" onChange={(e)=&amp;gt;{SetBody(e.target.value)}} required &amp;gt;
            &amp;lt;/textarea&amp;gt;

            &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
        &amp;lt;/form&amp;gt;
    &amp;lt;/div&amp;gt;

    );
}

export default CreateBlog;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;now we will create a blogslist view , where can see all blogs' list.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React, { useState, useEffect }from 'react'
import { Link } from "react-router-dom";
import fb from './firebase'


const db = fb.firestore()
const Blogs = db.collection('blogs');


const Bloglist = () =&amp;gt; {
    const [blogslist, setblogs] = useState([]);

    useEffect(() =&amp;gt; {
        // Subscribe to query with onSnapshot
        const unsubscribe = Blogs.limit(100).onSnapshot(querySnapshot =&amp;gt; {
          // Get all documents from collection - with IDs
          const data = querySnapshot.docs.map(doc =&amp;gt; ({
            ...doc.data(),
            id: doc.id,
          }));
          // Update state
          setblogs(data);
        });

        // Detach listener
        return unsubscribe;
      }, []);

    return (
        &amp;lt;div &amp;gt;

        &amp;lt;h2 className="w-full text-center font-bold text-xl"&amp;gt;All blogs List&amp;lt;/h2&amp;gt;

            {blogslist.map(blog=&amp;gt; (
                &amp;lt;div key={blog.id}&amp;gt;
    &amp;lt;p&amp;gt;Title : {blog.Title}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;body: {blog.Body} &amp;lt;/p&amp;gt;
    &amp;lt;Link to={"/blog/"+blog.id}
        class="mr-2 bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-1 px-2 border border-indigo-500 rounded"
        &amp;gt;View
    &amp;lt;/Link&amp;gt;
    &amp;lt;Link to={"/blog/edit/"+blog.id}
        class="mr-2 bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-2 border border-blue-500 rounded"
        &amp;gt;Edit
    &amp;lt;/Link&amp;gt;
&amp;lt;/div&amp;gt;          
            ))}
            ]]

    &amp;lt;/div&amp;gt;
    );
  };

export default Bloglist;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;now we will add Delete button to list. so we create a delete function.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

const Blogs = db.collection('blogs');

const DeleteBlog = (id)=&amp;gt; {
        Blogs.doc(id).delete().then(() =&amp;gt; {
            alert("Document successfully deleted!");
        }).catch((error) =&amp;gt; {
            console.error("Error removing document: ", error);
        });
    };


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;after creating a function , we have to create a button which will call this function. and gives the &lt;code&gt;id&lt;/code&gt; parameter to identify blog&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;button 
                            onClick={()=&amp;gt; {DeleteBlog(blog.id)}} 
                        &amp;gt;delete&amp;lt;/button&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;now complete &lt;code&gt;bloglist.js&lt;/code&gt; file look like this.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React, { useState, useEffect }from 'react'
import { Link } from "react-router-dom";
import fb from './firebase'


const db = fb.firestore()
const Blogs = db.collection('blogs');


const Bloglist = () =&amp;gt; {
    const [blogslist, setblogs] = useState([]);

    const DeleteBlog = (id)=&amp;gt; {
        Blogs.doc(id).delete().then(() =&amp;gt; {
            alert("Document successfully deleted!");
        }).catch((error) =&amp;gt; {
            console.error("Error removing document: ", error);
        });
    };

    useEffect(() =&amp;gt; {
        // Subscribe to query with onSnapshot
        const unsubscribe = Blogs.limit(100).onSnapshot(querySnapshot =&amp;gt; {
          // Get all documents from collection - with IDs
          const data = querySnapshot.docs.map(doc =&amp;gt; ({
            ...doc.data(),
            id: doc.id,
          }));
          // Update state
          setblogs(data);
        });

        // Detach listener
        return unsubscribe;
      }, []);

    return (
        &amp;lt;div &amp;gt;
        &amp;lt;h2 className="w-full text-center font-bold text-xl"&amp;gt;All blogs List&amp;lt;/h2&amp;gt;
            {blogslist.map(blog=&amp;gt; (
                &amp;lt;div key={blog.id}&amp;gt;
                    &amp;lt;p&amp;gt;Title : {blog.Title}&amp;lt;/p&amp;gt;
                    &amp;lt;p&amp;gt;body: {blog.Body} &amp;lt;/p&amp;gt;
                    &amp;lt;Link to={"/blog/"+blog.id}
                        class="mr-2 bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-1 px-2 border border-indigo-500 rounded"
                        &amp;gt;View
                    &amp;lt;/Link&amp;gt;
                    &amp;lt;Link to={"/blog/edit/"+blog.id}
                        class="mr-2 bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-2 border border-blue-500 rounded"
                        &amp;gt;Edit
                    &amp;lt;/Link&amp;gt;
                    &amp;lt;button 
                        onClick={()=&amp;gt; {DeleteBlog(blog.id)}} 
                    &amp;gt;delete&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            ))}
    &amp;lt;/div&amp;gt;
    );
  };

export default Bloglist;




&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;actually you can see we have already add two links in our list , which are &lt;code&gt;View&lt;/code&gt; link and &lt;code&gt;Edit&lt;/code&gt; link.&lt;/p&gt;

&lt;p&gt;before creating View and edit page we have to take a look on our routers. so we will add routers tag in our &lt;code&gt;app.js&lt;/code&gt; file&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;Router&amp;gt;
      &amp;lt;Navbar/&amp;gt;
    &amp;lt;Routes&amp;gt;
        &amp;lt;Route exact path='/' element={&amp;lt;Home/&amp;gt;} /&amp;gt;
        &amp;lt;Route exact path='/blog/' element={&amp;lt;Bloglist/&amp;gt;} /&amp;gt;

        &amp;lt;Route path='/blog/create' element={&amp;lt;CreateBlog/&amp;gt;}  /&amp;gt;
        &amp;lt;Route path='/blog/:id' element={&amp;lt;BlogView/&amp;gt;}  /&amp;gt;
        &amp;lt;Route path='/blog/edit/:id' element={&amp;lt;BlogEdit/&amp;gt;}  /&amp;gt;

    &amp;lt;/Routes&amp;gt;
    &amp;lt;/Router&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;we use Home, Bloglist , Createblog, BlogView and BlogEdit tags. so will import them from their files. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import CreateBlog from "./components/blogs/create";
import Bloglist from "./components/bloglist";
import BlogView from "./components/blogs/show";
import BlogEdit from "./components/blogs/edit";

import Home from "./components/pages/home";
import Navbar from "./components/temps/navbar";


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now our complete &lt;code&gt;app.js&lt;/code&gt; file will look like this&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import CreateBlog from "./components/blogs/create";
import Bloglist from "./components/bloglist";
import BlogView from "./components/blogs/show";
import BlogEdit from "./components/blogs/edit";

import Home from "./components/pages/home";
import Navbar from "./components/temps/navbar";

import React from "react";
import { BrowserRouter as Router, Routes, Route} from 'react-router-dom';

function App() {
  return (
    &amp;lt;Router&amp;gt;
      &amp;lt;Navbar/&amp;gt;
    &amp;lt;Routes&amp;gt;
        &amp;lt;Route exact path='/' element={&amp;lt;Home/&amp;gt;} /&amp;gt;
        &amp;lt;Route exact path='/blog/' element={&amp;lt;Bloglist/&amp;gt;} /&amp;gt;

        &amp;lt;Route path='/blog/create' element={&amp;lt;CreateBlog/&amp;gt;}  /&amp;gt;
        &amp;lt;Route path='/blog/:id' element={&amp;lt;BlogView/&amp;gt;}  /&amp;gt;
        &amp;lt;Route path='/blog/edit/:id' element={&amp;lt;BlogEdit/&amp;gt;}  /&amp;gt;

    &amp;lt;/Routes&amp;gt;
    &amp;lt;/Router&amp;gt;
  );
}

export default App;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we will create Edit.js for blogEdit and show.js to BlogView.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Show.js&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React, { useState }from 'react'
import { useParams } from "react-router-dom";


import fb from '../firebase';
const db = fb.firestore()
const Blogs = db.collection('blogs');


const BlogView = () =&amp;gt; {
    const { id } = useParams();

    const [blog, setblog] = useState([]); 
    Blogs.doc(id).get().then((snapshot) =&amp;gt; {
        const data = snapshot.data();
        setblog(data);
    });

    return (
        &amp;lt;div&amp;gt;
            &amp;lt;div className="w-full max-w-2xl mx-auto"&amp;gt;       
                &amp;lt;h1 className="text-2xl"&amp;gt;
                    &amp;lt;span&amp;gt;&amp;lt;b&amp;gt;Title :&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;
                    &amp;lt;span&amp;gt;{blog.Title}&amp;lt;/span&amp;gt;
                &amp;lt;/h1&amp;gt;
                &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Body :&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;
                &amp;lt;p&amp;gt;{blog.Body}&amp;lt;/p&amp;gt;

            &amp;lt;/div&amp;gt;            
        &amp;lt;/div&amp;gt;
    );
};

export default BlogView;





&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Edit.js&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React, { useEffect, useState }from 'react'
import { useParams } from "react-router-dom";


import fb from '../firebase';
const db = fb.firestore()
const Blogs = db.collection('blogs');


const BlogEdit = () =&amp;gt; {
    const { id } = useParams();

    const [title , SetTitle] = useState("");
    const [body , SetBody] = useState("");

    useEffect( (id)=&amp;gt; {
        Blogs.doc(id).get().then((snapshot) =&amp;gt; {
            const data = snapshot.data();
            SetTitle(data.Title);
            SetBody(data.Body);
        });
    },[]);

    const sub = (e) =&amp;gt; {
        e.preventDefault();

        // Add data to the store
        Blogs.doc(id).update({
            Title: title,
            Body: body,
            last_Updated: fb.firestore.Timestamp.fromDate(new Date())
        })
        .then((docRef) =&amp;gt; {
            alert("Data Successfully Updated");
        })
        .catch((error) =&amp;gt; {
            console.error("Error adding document: ", error);
        });
    }
    return (
        &amp;lt;div&amp;gt;

        &amp;lt;form onSubmit={(event) =&amp;gt; {sub(event)}}&amp;gt;    
            &amp;lt;input type="text" placeholder="Title"  value={title}
            onChange={(e)=&amp;gt;{SetTitle(e.target.value)}} required /&amp;gt;

            &amp;lt;textarea  name="content" type="text" value={body}
            placeholder="write yoyr content here" 
            rows="10" cols="150" onChange={(e)=&amp;gt;{SetBody(e.target.value)}} required &amp;gt;
            &amp;lt;/textarea&amp;gt;

            &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
        &amp;lt;/form&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

export default BlogEdit;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;now save your files and run &lt;code&gt;npm start&lt;/code&gt;.&lt;br&gt;
And Your project is ready.&lt;br&gt;
in this blog we will not discuss about styling. &lt;/p&gt;

&lt;p&gt;You can read source code from git repo &lt;a href="https://github.com/VipinBansal-Youtube/Blog-website-Using-Reactjs-and-Firebase" rel="noopener noreferrer"&gt;Click here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can watch youtube video of this blog.&lt;br&gt;
&lt;a href="https://youtu.be/GERuklicI8k" rel="noopener noreferrer"&gt;Watch&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to ask any doubt in comment section.&lt;br&gt;
Thank you for reading&lt;/p&gt;

</description>
      <category>react</category>
      <category>firebase</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
