<?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: rohanjsx</title>
    <description>The latest articles on DEV Community by rohanjsx (@rohanjsx).</description>
    <link>https://dev.to/rohanjsx</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%2F836763%2F005c8a4e-928f-4b96-aefb-fc260f95bbdd.jpeg</url>
      <title>DEV Community: rohanjsx</title>
      <link>https://dev.to/rohanjsx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rohanjsx"/>
    <language>en</language>
    <item>
      <title>Brush up map, filter and reduce in 5 minutes</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Tue, 12 Apr 2022 03:28:43 +0000</pubDate>
      <link>https://dev.to/rohanjsx/brush-up-map-filter-and-reduce-in-5-minutes-f3c</link>
      <guid>https://dev.to/rohanjsx/brush-up-map-filter-and-reduce-in-5-minutes-f3c</guid>
      <description>&lt;p&gt;Map, reduce, and filter are all array methods in JavaScript. Each one iterates over an array and performs a transformation or computation and returns a new array based on the result of the function.&lt;/p&gt;

&lt;h2&gt; Map &lt;/h2&gt;

&lt;p&gt;map method is used to create a new array from an existing one by applying a function to each element of the existing array. &lt;/p&gt;

&lt;p&gt;The callback function takes 3 arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;current element&lt;/li&gt;
&lt;li&gt;index&lt;/li&gt;
&lt;li&gt;the actual array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3wZ3tVwt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh0uh6wsm7bmgfsq93p7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3wZ3tVwt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh0uh6wsm7bmgfsq93p7.png" alt="map" width="880" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Polyfill for map() :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9xWEJWUt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j2orbmic3bpw598xacme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9xWEJWUt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j2orbmic3bpw598xacme.png" alt="polymap" width="880" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt; Filter &lt;/h2&gt;

&lt;p&gt;filter method takes each element in an array and applies a conditional statement against it. If the condition is fulfilled, only then the element is pushed to the result array.&lt;br&gt;
The callback function for filter takes the same 3 arguments as map();&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JtAYZdIu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rw9cks9rkg9wt8zamiq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JtAYZdIu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rw9cks9rkg9wt8zamiq4.png" alt="filter" width="880" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Polyfill for filter() :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gF-PuxFe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dtmeazvyclqgfjn64ow7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gF-PuxFe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dtmeazvyclqgfjn64ow7.png" alt="polyfil" width="880" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt; Reduce &lt;/h2&gt;

&lt;p&gt;reduce method reduces an array of elements down to a single output value. reduce() takes 2 arguments: the callback function &amp;amp; an initial value. If the initial value is not provided by the user, the first element of the array is taken as the initial value. The callback function takes 4 arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;accumulator (result of previous computations)&lt;/li&gt;
&lt;li&gt;current element&lt;/li&gt;
&lt;li&gt;index&lt;/li&gt;
&lt;li&gt;the actual array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mrAvIFrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zw8dc29rnad4xz41yzl3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mrAvIFrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zw8dc29rnad4xz41yzl3.png" alt="reduce" width="880" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Polyfill for reduce() :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cbvvsRn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ud9o2fqg4hnjexhbbo50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cbvvsRn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ud9o2fqg4hnjexhbbo50.png" alt="polyred" width="880" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; Example to sum it up: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1joZ5fvS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/my2zns7f9fvh3sx3kzkf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1joZ5fvS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/my2zns7f9fvh3sx3kzkf.png" alt="ex" width="880" height="966"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Build a Login/Signup Page with React &amp; TailwindCSS</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Sat, 02 Apr 2022 14:19:45 +0000</pubDate>
      <link>https://dev.to/rohanjsx/build-a-loginsignup-page-with-react-tailwindcss-27ab</link>
      <guid>https://dev.to/rohanjsx/build-a-loginsignup-page-with-react-tailwindcss-27ab</guid>
      <description>&lt;p&gt;A Login/Signup page is something you will find in every modern application whether it is an E-Commerce website or a Social Media application. In this beginner-friendly tutorial, we will build a simple Login/Signup page where you the user can toggle between Login and Signup with a single click.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React Hooks (Basic)&lt;/li&gt;
&lt;li&gt;CSS (Basic)&lt;/li&gt;
&lt;/ul&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%2F2cbtrvafwv27i9t1o06j.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%2F2cbtrvafwv27i9t1o06j.jpg" alt="sign"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; App Setup &lt;/h3&gt;

&lt;p&gt;Follow this &lt;a href="https://tailwindcss.com/docs/guides/create-react-app" rel="noopener noreferrer"&gt;doc&lt;/a&gt; to setup React app with TailwindCSS. This will take around 1-2 minutes. Once done, create a 'pages' folder in the 'src' directory and create a 'Login.jsx' page in the folder. For now, we will simply return the Login component and render it from our App.jsx as such:&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%2Fvnd1cky6chxvj4q9cbhp.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%2Fvnd1cky6chxvj4q9cbhp.png" alt="show"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Later, you can implement routing in your App and render it as such:&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%2Ffzd8klzrv16ufzrmda6d.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%2Ffzd8klzrv16ufzrmda6d.png" alt="route"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Design Login Form &lt;/h3&gt;

&lt;p&gt;In our Login page, let's create state variables for our inputs and to toggle between Login &amp;amp; SignUp forms:&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%2F1tgn8ehrv3sq3aug7yzx.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%2F1tgn8ehrv3sq3aug7yzx.png" alt="states"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When isLogin is true, we will display the Login form and when it is false, we will display the SignUp form. Let's go ahead and style the Login form!&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%2Foplcpfbl5c9svgpyf746.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%2Foplcpfbl5c9svgpyf746.jpg" alt="log"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's go ahead and style them as such:&lt;/p&gt;

&lt;p&gt;Our Login form can be divided into 4 parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Top (consisting App name and Sign In text)&lt;/li&gt;
&lt;li&gt;Social Icons container&lt;/li&gt;
&lt;li&gt;Inputs &amp;amp; Submit button&lt;/li&gt;
&lt;li&gt;Bottom info paragraph with toggle&lt;/li&gt;
&lt;/ul&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%2Fnjdpno9yqwiooghkyu3h.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%2Fnjdpno9yqwiooghkyu3h.png" alt="Top"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add a custom style for our socialIcon in the 'index.css':&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%2Frxa6w90lblocx6uzc522.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%2Frxa6w90lblocx6uzc522.png" alt="social"&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%2Fkxf2ixa6i8hc7min21yl.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%2Fkxf2ixa6i8hc7min21yl.png" alt="Icons"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's finish up by styling our inputs and the bottom section where we will add an onClick handler so that we can switch from 'Login' to 'Signup' on clicking the 'Create Account' paragraph.&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%2Flo3n199304krrvrsdt1o.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%2Flo3n199304krrvrsdt1o.png" alt="button"&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%2Fupb3yycp5ba89krjwjbw.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%2Fupb3yycp5ba89krjwjbw.png" alt="toggler"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's put it all together and create our LoginForm component:&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%2Fppwmkh51optj69sdql5y.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%2Fppwmkh51optj69sdql5y.png" alt="complete"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, we can go ahead and create our SignUp form component and customize it as per our need. For now, we will add an Username and an Avatar URL input field and change the background color for our SignUp Form:&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%2Fqwuvq2ezul3imrqlai2b.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%2Fqwuvq2ezul3imrqlai2b.png" alt="register"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To put it all together, we need to conditionally render the Login/Signup form based on the isLogin state as such:&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%2Fubggegh3sv3709q054oq.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%2Fubggegh3sv3709q054oq.png" alt="switch"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/vafS3QxrgAgllKYSr7/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/vafS3QxrgAgllKYSr7/giphy.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And just like that, we have our Login page setup where the user can switch between Login &amp;amp; Signup with a single click!&lt;br&gt;
Feel free to customize it as your own and add animations and your app logo!&lt;/p&gt;

&lt;h4&gt; Resources: &lt;/h4&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;TailwindCSS&lt;/a&gt;&lt;br&gt;
&lt;a href="https://reactjs.org/docs/hooks-state.html" rel="noopener noreferrer"&gt;React Hooks&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gist.github.com/kishibe-rohan/0ff4a6c0d435f83998ee119f3687ed6b" rel="noopener noreferrer"&gt;Code Gist&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Build A MERN Stack App in 5 Days (Day 5: Finishing Up)</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Wed, 30 Mar 2022 03:28:03 +0000</pubDate>
      <link>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-5-finishing-up-4f1m</link>
      <guid>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-5-finishing-up-4f1m</guid>
      <description>&lt;p&gt;Hello &amp;amp; welcome to the final chapter of this series!&lt;br&gt;
In the previous parts,we:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setup the backend&lt;/li&gt;
&lt;li&gt;Designed the stateless components in the frontend&lt;/li&gt;
&lt;li&gt;Setup Redux &amp;amp; Firebase Auth&lt;/li&gt;
&lt;li&gt;Connected our frontend to backend to add &amp;amp; fetch questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The only functionality remaining to complete our app is to 'Add Answer'. So, in this tutorial we will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add axios request to 'Add Answer'&lt;/li&gt;
&lt;li&gt;Create a Modal to 'Add Answer'&lt;/li&gt;
&lt;li&gt;Design our Posts component and Feed&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt; Design the Feed &lt;/h2&gt;

&lt;p&gt;The post component in our final version of the app looks like this:&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%2F67936ql1s1g8ty8w29do.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%2F67936ql1s1g8ty8w29do.png" alt="post"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon clicking the 'Answer' button, we want a Modal to pop-up with an area to write our answer and submit it. So, let's setup our app accordingly. Let's go ahead and make a request to fetch all the posts from our backend in our 'Feed' and pass them as props to the 'Post' component as such:&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%2Fo0x7lwo9zz2qrmy87wrg.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%2Fo0x7lwo9zz2qrmy87wrg.png" alt="get"&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%2Fxpqw3swdswkab4h74osl.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%2Fxpqw3swdswkab4h74osl.png" alt="post"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's design the 'Post Component'! As we saw in the image above, our Post component can be divided into 4 parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Top (containing User avatar and name)&lt;/li&gt;
&lt;li&gt;Middle (containing the Question, the Answer button &amp;amp; Image'&lt;/li&gt;
&lt;li&gt;Buttons (Utility buttons for Like, Dislike, Share, Comment&lt;/li&gt;
&lt;li&gt;Button to toggle show/hide answers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will be using the 'react-quill' , 'react-time-ago' and 'react-html-parser' libraries in the Post component. Additionally, we need to create a function to handle answer submission:&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%2Fc2505b8uuzqyhobum4pc.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%2Fc2505b8uuzqyhobum4pc.png" alt="handle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, we will have state variables to control our state:&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%2Fgd5c04o1pxy0g8my8x05.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%2Fgd5c04o1pxy0g8my8x05.png" alt="states"&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%2Ftcbtk7kb8hpqvlg6wtyx.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%2Ftcbtk7kb8hpqvlg6wtyx.png" alt="quill"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we can go ahead and design the Post component:&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%2Fqfbv46yqvyp8fptr0kzr.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%2Fqfbv46yqvyp8fptr0kzr.png" alt="top"&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%2F6lcug82zj6gfidqhg0c0.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%2F6lcug82zj6gfidqhg0c0.png" alt="modal"&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%2F1rxqgb0fsj2fjywsk8n6.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%2F1rxqgb0fsj2fjywsk8n6.png" alt="utility"&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%2Foajoq97f5gjs57i15qyx.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%2Foajoq97f5gjs57i15qyx.png" alt="toggle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, if we click on the 'Answer' button we will have our Modal pop-up with our quill where we can submit our answer!&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%2Fezr5fs4un52cuep0pu4r.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%2Fezr5fs4un52cuep0pu4r.png" alt="quill"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Conclusion &lt;/h3&gt;

&lt;p&gt;And with that, we have a fully-functional MERN stack social app with the functionalities of Add Question, Add Answer &amp;amp; Google Sign-In! Feel free to build upon this prototype and add your own features and fully customize this app and turn it into a complete social application!&lt;/p&gt;

&lt;h4&gt; Features to improve the App: &lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Add a Categories model &amp;amp; filter Posts by Category&lt;/li&gt;
&lt;li&gt;Add features to like, comment and share&lt;/li&gt;
&lt;li&gt;Add features to fetch all posts from a specific user&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt; Resources &lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/kishibe-rohan/kysymys" rel="noopener noreferrer"&gt;Code Repo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;TailwindCSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redux.js.org/" rel="noopener noreferrer"&gt;Redux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://axios-http.com/docs/intro" rel="noopener noreferrer"&gt;Axios&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope you had fun &amp;amp; learned something new in this 5-part series!&lt;br&gt;
Thank you for reading along!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>Build A MERN Stack App in 5 Days (Day 4: Connecting to the backend)</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Tue, 29 Mar 2022 04:02:00 +0000</pubDate>
      <link>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-4-connecting-to-the-backend-3cof</link>
      <guid>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-4-connecting-to-the-backend-3cof</guid>
      <description>&lt;p&gt;Hello and Welcome to Day 4!&lt;br&gt;
Up to this point, we have setup our backend, designed the Sidebar, Header &amp;amp; Widgets components and implemented Login &amp;amp; Logout functionalities for our user with Redux &amp;amp; Firebase Google Auth.&lt;/p&gt;

&lt;p&gt;Today, we will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Design 'Modal' to Add Question&lt;/li&gt;
&lt;li&gt;Make request to backend to add question to DB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's get started!&lt;/p&gt;

&lt;h2&gt; Add Question &lt;/h2&gt;

&lt;p&gt;Our Question has 3 fields: description, imageUrl (optional) and user. The user field will be accessible from our Redux global store once the user signs in. Then, we want to display a 'Modal' once the user clicks on the 'Add Question' button in the &lt;em&gt;Header&lt;/em&gt; where the user can enter the description &amp;amp; imageUrl and submit the question. Let's go ahead and:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install the dependencies we will use today &lt;/li&gt;
&lt;li&gt;Add a proxy to our backend server in 'package.json' in client&lt;/li&gt;
&lt;li&gt;Create states to keep track of input fields:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i1Yp0lip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fjqluqw7h0xtd3c9tqiz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i1Yp0lip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fjqluqw7h0xtd3c9tqiz.png" alt="install" width="880" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iWZ0RU6D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xaw54ezj20zh61cq5k7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iWZ0RU6D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xaw54ezj20zh61cq5k7.png" alt="states" width="880" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F547nNVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68k8d1l3rg6witnkhala.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F547nNVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68k8d1l3rg6witnkhala.png" alt="proxy" width="880" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: You can use any library of your choice to create the modal or create a custom 'Modal' component yourself&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's create the function to make the request to the backend to submit our question:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6LZeNMTe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rb4fy2lpocmq3lad4k09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6LZeNMTe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rb4fy2lpocmq3lad4k09.png" alt="add" width="880" height="769"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt; Design the Modal &lt;/h2&gt;

&lt;p&gt;On clicking the 'Add Question' button, we set the 'isModalOpen' state to true and display our modal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oyOKC241--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/piz6sl1qv3dpi9rhe1w2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oyOKC241--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/piz6sl1qv3dpi9rhe1w2.png" alt="set" width="880" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our final version of the Modal in the app looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--264S6JVX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fhsoe0nazvp4nu59cen.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--264S6JVX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fhsoe0nazvp4nu59cen.png" alt="mode" width="880" height="648"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be divided into the following sections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Top (containing the texts Add Question &amp;amp; Share Link)&lt;/li&gt;
&lt;li&gt;Middle (containing Avatar and Dropdown)&lt;/li&gt;
&lt;li&gt;Inputs &amp;amp; Image Preview&lt;/li&gt;
&lt;li&gt;Buttons to Submit Question &amp;amp; Close Modal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dXOZxVwS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nj8rp9rtbf6l1pognuj8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dXOZxVwS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nj8rp9rtbf6l1pognuj8.png" alt="top" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eku0r1GV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6btac2t1c3bfz0zlt4c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eku0r1GV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6btac2t1c3bfz0zlt4c.png" alt="middle" width="880" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s3t0NTMs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzf9x4uku2fqzb86kpvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s3t0NTMs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzf9x4uku2fqzb86kpvi.png" alt="inputs" width="880" height="893"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a5ZIs4o3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1hhqa7ux4jqz5vhwq0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a5ZIs4o3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1hhqa7ux4jqz5vhwq0q.png" alt="buttons" width="880" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's go ahead and test our Modal!&lt;br&gt;
Run 'npm start' in the terminal from the 'client' directory.&lt;br&gt;
The app should run on localhost:3000. Login and click on the 'Add Question' button and the Modal should pop up! Go ahead and Add a Question.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--izhrb2WM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xr83yoo37354t1kf4lpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--izhrb2WM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xr83yoo37354t1kf4lpz.png" alt="will" width="880" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we go and check our MongoDB database,we see that the Question has been added to our database successfully!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kMftxBg2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inprffzex2uu92s6iazw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kMftxBg2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inprffzex2uu92s6iazw.png" alt="db add" width="880" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the 'Add Question' functionality out of the way, the only functionality we are missing is to 'Add Answer'.&lt;/p&gt;

&lt;p&gt;In the next and final part of the series, we will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add functionality to Submit Answer&lt;/li&gt;
&lt;li&gt;Design our Feed&lt;/li&gt;
&lt;li&gt;Polish and wrap up our application!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt; Homework &lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Design your own custom Modal component&lt;/li&gt;
&lt;li&gt;Add a custom alert to display 'Question Added' when you submit the question&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See you in the final part!&lt;/p&gt;

</description>
      <category>react</category>
      <category>mongodb</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build A MERN Stack App in 5 Days (Day 3: Setting up Redux &amp; Firebase Login)</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Mon, 28 Mar 2022 04:18:17 +0000</pubDate>
      <link>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-3-setting-up-redux-firebase-login-5ae</link>
      <guid>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-3-setting-up-redux-firebase-login-5ae</guid>
      <description>&lt;p&gt;Welcome to Day 3! In the previous two parts, we have set up our backend and designed the Header, Sidebar &amp;amp; Widgets components in our UI. Before we design the Feed component, we need to implement User Authentication so that we can fetch our posts from the database. What we'll do today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement Firebase Google Auth&lt;/li&gt;
&lt;li&gt;Setup Redux&lt;/li&gt;
&lt;li&gt;Add Login &amp;amp; Logout functionalities &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt; Firebase Auth &lt;/h2&gt;

&lt;p&gt;Head over to &lt;a href="https://console.firebase.google.com/u/1/" rel="noopener noreferrer"&gt;https://console.firebase.google.com/u/1/&lt;/a&gt; and 'Add project'. Name your project and Create a new 'Web' application and copy/paste the SDK configuration.&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%2F68tc1sab97zdfnkmmshp.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%2F68tc1sab97zdfnkmmshp.png" alt="sdk"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Go to the 'Authentication' tab and in the 'Sign-in methods',enable Google &lt;/b&gt; . Go ahead and install Firebase in the 'client' directory by using 'npm i firebase'. Create a file named 'firebase.js' in the 'src' folder and copy paste the Firebase configuration alongwith some other imports as such:&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%2Fkge56gpsqh8bti9587la.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%2Fkge56gpsqh8bti9587la.png" alt="config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt; Redux &lt;/h2&gt;

&lt;p&gt;Go ahead and install 'react-redux' and '@reduxjs/toolkit'. Create a folder called 'features' in the src directory and create a new file called 'userSlice.js' in the features folder. This file will include the reducers and actions, namely login and logout for our user. In the userSlice.js:&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%2Fpky09n6pr2d93kbfdo0t.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%2Fpky09n6pr2d93kbfdo0t.png" alt="user"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a 'store.js' file in the src directory where we import our userSlice and initialize the global store, so that we can use it anywhere in our app and avoid prop drilling!&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%2Fitoc9h7t9f0hnooy20og.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%2Fitoc9h7t9f0hnooy20og.png" alt="store"&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%2Fk93wryn6yrws595j8vh8.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%2Fk93wryn6yrws595j8vh8.png" alt="index"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With our global Redux store &amp;amp; Firebase Auth set up,all that's left to do is create a Login page which will leverage the Firebase Auth to enable User Login and fill our global user object.&lt;/p&gt;

&lt;h3&gt; Login &lt;/h3&gt;

&lt;p&gt;In the 'pages' directory, create a 'Login.jsx' file. For now,it will be a simple page with a Logo and a Login Button. Feel free to customize it as per your needs and add more Authentication Providers!&lt;br&gt;
Let's create a 'handleLogin' utility function which will do just what it's name suggests.&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%2Fpezykffwywx2divsu87x.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%2Fpezykffwywx2divsu87x.png" alt="handle"&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%2Fjqvcru6lmbb53pr397hu.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%2Fjqvcru6lmbb53pr397hu.png" alt="loginpage"&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%2Fkytjk1eahvgswq0r0zc8.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%2Fkytjk1eahvgswq0r0zc8.png" alt="logpage"&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%2Fq237276nb31rp7mpsjnj.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%2Fq237276nb31rp7mpsjnj.png" alt="modal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now,in our App.js let's render Login page/Home page depending upon the user's auth state. The user can visit the 'Home' page only after they have logged in.&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%2F4lp9tzx6zxk15uz1mzjw.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%2F4lp9tzx6zxk15uz1mzjw.png" alt="app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt; Logout &lt;/h2&gt;

&lt;p&gt;With the Login functionality done, lets add an option to Logout when the user clicks on their Avatar in the Header. Head over to 'Header.jsx' in the 'components' directory.&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%2Fknqn8y1bdbmfpv5bxlcl.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%2Fknqn8y1bdbmfpv5bxlcl.png" alt="loghand"&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%2Fyu9ersr878t3fce3ptp8.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%2Fyu9ersr878t3fce3ptp8.png" alt="logout"&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%2Ftqvd0hvk3zqsddlzx5xf.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%2Ftqvd0hvk3zqsddlzx5xf.png" alt="hello"&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%2Fdzz3njytkhkdd3fb2o29.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%2Fdzz3njytkhkdd3fb2o29.png" alt="sure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With our login &amp;amp; logout functionalities implemented, in the next part we will add functionality to Add Question and Fetch Question from our database and render it in the Feed component, making our application fully functional.&lt;/p&gt;

&lt;h3&gt; Homework &lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add more Providers for Login (Github/Facebook)&lt;/li&gt;
&lt;li&gt;Customize the Login page &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt; References &lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/kishibe-rohan/kysymys-tutorial" rel="noopener noreferrer"&gt;Code Repo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://redux-toolkit.js.org/" rel="noopener noreferrer"&gt;Redux Toolkit&lt;/a&gt;&lt;br&gt;
&lt;a href="https://console.firebase.google.com/u/1/" rel="noopener noreferrer"&gt;Firebase&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you in the next part!&lt;/p&gt;

</description>
      <category>react</category>
      <category>firebase</category>
      <category>redux</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build A MERN Stack App in 5 Days (Day 2: Getting started with the Frontend)</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Sun, 27 Mar 2022 07:59:34 +0000</pubDate>
      <link>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-2-getting-started-with-the-frontend-5e3i</link>
      <guid>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-2-getting-started-with-the-frontend-5e3i</guid>
      <description>&lt;p&gt;Hello and welcome to part 2!&lt;br&gt;
In the previous part, we setup our backend server, created our models and routes and connected to our MongoDB database. In today's part, we will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Setup React + Tailwind CSS&lt;/li&gt;
&lt;li&gt; Setup the folder structure for our frontend&lt;/li&gt;
&lt;li&gt; Create the Header, Sidebar &amp;amp; Widgets components
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Prerequisites&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSS Flexbox&lt;/li&gt;
&lt;li&gt;TailwindCSS (Basic)&lt;/li&gt;
&lt;li&gt;React (Basic) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what the 'Home' page on our final version of the app looks like:&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%2Fykehlbq30no34az8q815.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%2Fykehlbq30no34az8q815.png" alt="desk"&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%2Fz4xrlxfa755x46kfd7cy.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%2Fz4xrlxfa755x46kfd7cy.png" alt="mobile"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is mobile responsive and we can divide the page into 4 sections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Header&lt;/li&gt;
&lt;li&gt;Sidebar&lt;/li&gt;
&lt;li&gt;Feed&lt;/li&gt;
&lt;li&gt;Widgets&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt; Setup &lt;/h3&gt;

&lt;p&gt;To setup the frontend project, navigate to the 'client' folder and follow this short &amp;amp; concise &lt;a href="https://tailwindcss.com/docs/guides/create-react-app" rel="noopener noreferrer"&gt;doc&lt;/a&gt; to setup the boilerplate for a basic React App with Tailwind CSS . This will take about 1-2 minutes.&lt;/p&gt;

&lt;p&gt;Once done, navigate to the 'src' folder and go ahead and delete the files we won't be needing, only keep the following files in the 'src':&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;App.js&lt;/li&gt;
&lt;li&gt;index.js&lt;/li&gt;
&lt;li&gt;index.css&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure to delete the code in all three files and we shall start from scratch! This is what these 3 files should look like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;App.js&lt;/li&gt;
&lt;/ul&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%2F5sm8qvmziakw34ls00ff.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%2F5sm8qvmziakw34ls00ff.png" alt="app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;index.js&lt;/li&gt;
&lt;/ul&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%2Fn8dy8xin6kiq8dhf16ci.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%2Fn8dy8xin6kiq8dhf16ci.png" alt="index"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;index.css&lt;/li&gt;
&lt;/ul&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%2Fpc2i2ej2mqoy1zi6nfbg.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%2Fpc2i2ej2mqoy1zi6nfbg.png" alt="css"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, go ahead and create two folders in the 'src' directory, namely 'components' and 'pages'. In the components folder, create 4 new files, namely 'Header.jsx', 'Sidebar.jsx', 'Widgets.jsx' and 'Feed.jsx' and for the time-being, initialize them as such:&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%2Fd6vj3h5434wrfry8uu0d.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%2Fd6vj3h5434wrfry8uu0d.png" alt="feed"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Do the same for Sidebar, Header and Widgets components and import them in the new 'Home.jsx' file in the 'pages' directory:&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%2Fl39gu0p40c8tvprtr0f1.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%2Fl39gu0p40c8tvprtr0f1.png" alt="home"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go ahead and export the 'Home' component in the App.js in 'src' and render them as such:&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%2Fljrq0ix9kadxnimt42ii.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%2Fljrq0ix9kadxnimt42ii.png" alt="apps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run 'npm start' in the terminal once you are in the 'client' directory and this is what our site looks like for now:&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%2Ffyffzm1fadp49ur15zuo.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%2Ffyffzm1fadp49ur15zuo.png" alt="demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's apply some Tailwind utility classes to our 'Home' to align the items properly and setup our layout as follows:&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%2Fgoz9p25hzgciwd9oxft6.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%2Fgoz9p25hzgciwd9oxft6.png" alt="tc"&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%2Flohdy4jx8ebd8d40m9a7.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%2Flohdy4jx8ebd8d40m9a7.png" alt="lay"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's go ahead and style the individual components one by one. We will go over the Header component in detail, applying Tailwind utility classes and discuss adding custom Tailwind classes. We will discuss the Sidebar &amp;amp; Widgets components in brief. Later, you can go ahead and apply your own styles and make the application your own. Let's get started with the Header!&lt;/p&gt;

&lt;h2&gt; Header &lt;/h2&gt;

&lt;p&gt;Before we start coding the header, we need to install two packages: @material-ui/core and @material-ui/icons which we will use for the icons and components like Button, Input, Avatar in our application. Alternatively, you can use '@headless-ui/react' and '@heroicons/react' for this purpose.&lt;/p&gt;

&lt;p&gt;Our Header will be divided into 3 sections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Left (Our logo)&lt;/li&gt;
&lt;li&gt;Center (Icons &amp;amp; Searchbar)&lt;/li&gt;
&lt;li&gt;Right (Avatar &amp;amp; Add Post button)&lt;/li&gt;
&lt;/ul&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%2Fsth65odae08wto31plyp.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%2Fsth65odae08wto31plyp.png" alt="headset"&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%2Fbd3j68bv875i8aph7tjl.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%2Fbd3j68bv875i8aph7tjl.png" alt="sethead"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to apply 'flex' to our Header to align the items in a row and in the meantime let's apply some styling to our logo, feel free to replace this with an image of your app logo.&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%2Ftgl67eo2k4yosid25arq.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%2Ftgl67eo2k4yosid25arq.png" alt="span"&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%2F4mca929lb95rikxx6sg4.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%2F4mca929lb95rikxx6sg4.png" alt="flex"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we are gonna create our first custom TailwindCSS class to style our header icons, head over to index.css and add the following:&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%2Fkp9085ppa29hr1a36i4u.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%2Fkp9085ppa29hr1a36i4u.png" alt="custom"&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%2F7aq938wooz4j90u8pby7.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%2F7aq938wooz4j90u8pby7.png" alt="add"&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%2F2rqfjy6om586p8jeerw3.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%2F2rqfjy6om586p8jeerw3.png" alt="search"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add the Avatar and 'Add Question' button and style it up to finish our Header design.&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%2F4pqbo7zp6z5azv662nn8.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%2F4pqbo7zp6z5azv662nn8.png" alt="style"&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%2F89nwg6rgxsax1f35xokb.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%2F89nwg6rgxsax1f35xokb.png" alt="file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the same way, let's style our Sidebar and Widgets!&lt;/p&gt;

&lt;h2&gt; Sidebar &lt;/h2&gt;

&lt;p&gt;In the 'components' folder, create a SidebarItems.jsx file and import it into the Sidebar.jsx fil and style it as such with some more custom TailwindCSS classes!&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%2Fq3z9wzzc10giczgn159p.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%2Fq3z9wzzc10giczgn159p.png" alt="sideclass"&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%2Ffobcfp73el17ln5tlt45.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%2Ffobcfp73el17ln5tlt45.png" alt="content"&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%2Fmk6ttqkysyscf9wygt8y.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%2Fmk6ttqkysyscf9wygt8y.png" alt="sidebars"&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%2Fowqnz06qwml6b5c3dgtv.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%2Fowqnz06qwml6b5c3dgtv.png" alt="shot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt; Widgets &lt;/h2&gt;

&lt;p&gt;Similarly, for the Widgets component, let's create a WidgetContent.jsx file and style it with custom TailwindCSS classes and import it in the Widgets.jsx!&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%2Fwlop2m1c4b9ngb7drs7b.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%2Fwlop2m1c4b9ngb7drs7b.png" alt="widstyle"&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%2Fesvxt70e5o3vbdb1fhxl.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%2Fesvxt70e5o3vbdb1fhxl.png" alt="widcomp"&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%2F2uct2yrwhlgwdbefflfa.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%2F2uct2yrwhlgwdbefflfa.png" alt="contain"&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%2F65za4o7s6zhwywbp7me7.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%2F65za4o7s6zhwywbp7me7.png" alt="view"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Final Touches &lt;/h3&gt;

&lt;p&gt;As of now, the Feed seems to be of around the same width as Sidebar and Widgets components. However, we want the Sidebar and Widgets to each take up 20% of the screen on large screens and the Feed to take up 60% of the screen. In smaller screens, we want the Sidebar and Widgets to be hidden and the Feed to take up the entire space. Keeping that in mind, we apply the following styles:&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%2Fa0c12othex02z5hknqdu.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%2Fa0c12othex02z5hknqdu.png" alt="feeder"&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%2Fdu85i04qu8ijy8lb70o6.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%2Fdu85i04qu8ijy8lb70o6.png" alt="final"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next part of the series, we will implement Firebase Google Auth and Login and then make requests to our backend to Add and Fetch posts from our database and create the Feed!&lt;/p&gt;

&lt;h3&gt; Homework(Suggestions to practice) &lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Replace the logo in the 'Header' with your own custom logo.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Replace the multiple divs in the SidebarItems component by mapping over an array to make the code cleaner. (Plus points if you fetch this data from some API)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do the same for the Widgets Component!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use headlessui + heroicons instead of Material UI&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt; Resources &lt;/h4&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;TailwindCSS&lt;/a&gt;&lt;br&gt;
&lt;a href="https://mui.com/components/material-icons/" rel="noopener noreferrer"&gt;Icons&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/kishibe-rohan/kysymys-tutorial" rel="noopener noreferrer"&gt;Code Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you in part 3!&lt;/p&gt;

</description>
      <category>react</category>
      <category>tailwindcss</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build A MERN Stack App in 5 Days (Day 1: Setting up the backend)</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Sat, 26 Mar 2022 04:59:20 +0000</pubDate>
      <link>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-1-setting-up-the-backend-44fe</link>
      <guid>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-1-setting-up-the-backend-44fe</guid>
      <description>&lt;p&gt;Hello! Welcome to part 1 of the series.. Today, we will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;set up our backend &lt;/li&gt;
&lt;li&gt;connect to MongoDB&lt;/li&gt;
&lt;li&gt;create Models&lt;/li&gt;
&lt;li&gt;create Routes &amp;amp; their functions (controllers)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prerequisites: Basic knowledge of Express &amp;amp; MongoDB&lt;/p&gt;

&lt;p&gt;Before we get to coding, let's plan out our models so that we are all on the same page. The two main models for our application will be: &lt;strong&gt;Questions&lt;/strong&gt; and &lt;strong&gt;Answers&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Every &lt;strong&gt;Question&lt;/strong&gt; will have a:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;description&lt;/li&gt;
&lt;li&gt;imageURL (optional)&lt;/li&gt;
&lt;li&gt;answers&lt;/li&gt;
&lt;li&gt;createdAt&lt;/li&gt;
&lt;li&gt;user (the user who submitted the question)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every &lt;strong&gt;Answer&lt;/strong&gt; will have a:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;answer (the actual answer submitted by the user)&lt;/li&gt;
&lt;li&gt;questionID (id of the question it is answering)&lt;/li&gt;
&lt;li&gt;createdAt&lt;/li&gt;
&lt;li&gt;user (the user who submitted the answer)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Okay, so let's start coding!&lt;br&gt;
We will have two separate folders: &lt;em&gt;client&lt;/em&gt; &amp;amp; &lt;em&gt;server&lt;/em&gt; . The 'client' folder will contain our frontend code and the 'server' folder will include our backend code. Today, we will be working in the server directory so make sure you are in the correct directory! Once we are in the server directory, we'll need to initialize our package.json with &lt;em&gt;npm init&lt;/em&gt; and install the dependencies. Our dependencies will be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Express&lt;/strong&gt;: Our server framework &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mongoose&lt;/strong&gt; : To communicate with our MongoDB database&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CORS&lt;/strong&gt;: Middleware used to enable CORS with various options.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BodyParser&lt;/strong&gt;: Middleware for parsing incoming request bodies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dotenv&lt;/strong&gt;: To load our environment variables in development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, go ahead in your terminal once you are in the server directory&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%2Fq6ublplqjv5p9empu0ec.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%2Fq6ublplqjv5p9empu0ec.png" alt="Init"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Models &lt;/h3&gt;

&lt;p&gt;Let's go ahead and code our Models! Create a separate folder called 'models' in the server directory and create two separate files: QuestionModel.js and AnswerModel.js and let's go ahead and code our models as we discussed earlier.&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%2F5lmy5r6m7cg3su3pqvym.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%2F5lmy5r6m7cg3su3pqvym.png" alt="QModel"&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%2Fh3q4mxz81t4e3eb8gjh1.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%2Fh3q4mxz81t4e3eb8gjh1.png" alt="AModel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Routes &lt;/h3&gt;

&lt;p&gt;With our models ready, next we need to setup our routes and their controllers. For now, we will have three controllers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add Question&lt;/strong&gt; : triggered upon a POST request to the route '/api/questions'. Takes in the fields description, imageURL, user from the request body and adds the new question to the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add Answer&lt;/strong&gt; : triggered upon a POST request to the route '/api/answers'. Takes in the fields answer, questionID, user from the request body and adds the new answer to the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Get All Questions&lt;/strong&gt; : triggered upon a GET request to the route '/api/questions'. Returns all the questions in the database alongwith all their answers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, create a new folder called 'routes' in the server directory with two files: QuestionRoutes.js &amp;amp; AnswerRoutes.js.. QuestionRoutes will contain Add Question &amp;amp; Get All Questions while AnswerRoutes will contain a single controller for now which is Add Answer. So, go ahead and in QuestionRoutes.js :&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%2Fph2k32bcpmenkj8x7igf.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%2Fph2k32bcpmenkj8x7igf.png" alt="QRoutes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in AnswerRoutes.js :&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%2Fqph884yzo8qfmiwnm9lr.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%2Fqph884yzo8qfmiwnm9lr.png" alt="Aroutes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go ahead and create an index.js file in the 'routes' folder and import all our routes:&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%2F3u8eslhyah4abyk5lxp9.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%2F3u8eslhyah4abyk5lxp9.png" alt="Allroutes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Connect to MongoDB &lt;/h3&gt;

&lt;p&gt;Now, with our Models &amp;amp; Routes set up ,let's go ahead and actually connect to our database. We will be using Cloud MongoDB Atlas for our database, so go ahead and login/register on cloud.mongodb.com and 'Add New Project' &amp;gt; 'Create a Database':&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%2Fy96xmigas6te7nmfsvty.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%2Fy96xmigas6te7nmfsvty.png" alt="createDB"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The cluster provisioning takes around 3-5 minutes. In the meantime, go to the 'Database Access' tab and 'Add New Database User', after that go to the 'Network Access' and add the IP Address '0.0.0.0' to the IP Access List!&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%2F4jc1ll7hd1uto5erph19.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%2F4jc1ll7hd1uto5erph19.png" alt="adduser"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Once the cluster is provisioned, click on 'Connect' &amp;gt; 'Connect your MongoDB application' and copy the connection string,this will be our &lt;strong&gt;MongoURI&lt;/strong&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%2Fh6rshapb2anz5bsme5o0.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%2Fh6rshapb2anz5bsme5o0.png" alt="cluster"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now create a '.env' file in your the server directory and:&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%2Fbzvkm8kluqah72e0q0iu.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%2Fbzvkm8kluqah72e0q0iu.png" alt="env"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Make sure to replace the 'password' field with the password for your user and 'myFirstDatabase' with the name of your database!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, go ahead and create a 'db.js' file in the 'server' directory where we will write a function to establish connection with our database.&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%2Ffvh5fa9i1puun9m8vmve.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%2Ffvh5fa9i1puun9m8vmve.png" alt="db"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Putting it all together &lt;/h3&gt;

&lt;p&gt;So far, we have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Created our Models&lt;/li&gt;
&lt;li&gt;Created our Routes&lt;/li&gt;
&lt;li&gt;Setup MongoDB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let's go ahead and put it all together for our backend, where we create an 'index.js' file which will be our main file in the server directory, where we will listen on our server, setup middlewares and connect to our database!&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%2F1ya9da71bokqcawu9gv6.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%2F1ya9da71bokqcawu9gv6.png" alt="Index"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the final step, we need to add a 'start' script in our package.json:&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%2Fzlosc64dewhdaztngphs.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%2Fzlosc64dewhdaztngphs.png" alt="package"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, go ahead and type 'npm start' in the terminal to start our server and if everything is done right, we should see:&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%2Fuyu1g3hx48xin1y11ofp.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%2Fuyu1g3hx48xin1y11ofp.png" alt="start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Additional | Testing with Postman &lt;/h3&gt;

&lt;p&gt;Go ahead and test the routes with Postman or your favorite API Testing tool.. Try adding some dummy data and make sure it populates the database.&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%2Fde5xm1xouxu6s90reohr.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%2Fde5xm1xouxu6s90reohr.png" alt="postman"&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%2Fd95ae7hnjqieq2qbnvxt.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%2Fd95ae7hnjqieq2qbnvxt.png" alt="populate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Conclusion &lt;/h3&gt;

&lt;p&gt;So today, we setup our backend, our models, routes, connected to MongoDB and started our server. Join in for part 2 where we start working on the frontend and setup React + TailwindCSS&lt;/p&gt;

&lt;h4&gt; Homework &lt;/h4&gt;

&lt;p&gt;Unlike most coding tutorials where the reader has to just copy paste the code, in this tutorial I just wanted to show the exhibit functionalities and leave ample space for the reader to add more additional assignments of their own, where the reader can improve upon the app and add functionalities of their own and learn by practice.. Some functionalities you can add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a 'Category' model or add a 'category' field to Questions and add a route to get Questions according to category.&lt;/li&gt;
&lt;li&gt;Make the answer route protected i.e. allow access to the route only after user is authenticated. You can use 'passport' or some other package for this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/kishibe-rohan/kysymys-tutorial" rel="noopener noreferrer"&gt;Code repository&lt;/a&gt;&lt;br&gt;
Feel free to fork and add your own touch to the project! &lt;br&gt;
Reach out to me for any issues/queries.&lt;br&gt;
See you in Part 2!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>mongodb</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build a MERN Stack App in 5 Days (The Introduction)</title>
      <dc:creator>rohanjsx</dc:creator>
      <pubDate>Fri, 25 Mar 2022 16:10:12 +0000</pubDate>
      <link>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-the-introduction-19i7</link>
      <guid>https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-the-introduction-19i7</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What we will create&lt;/strong&gt;: &lt;em&gt;Kysymys&lt;/em&gt; - A MERN Stack social question and answer site similar to Quora with functionalities of User Authentication, Posting a Question, Submitting Answers to Questions, etc.

&lt;/li&gt;
&lt;/ul&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%2Frhh2lcvekxsdleabkr70.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%2Frhh2lcvekxsdleabkr70.png" alt="Kysymys"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What tools will we be using&lt;/strong&gt;: &lt;em&gt;React&lt;/em&gt; for frontend + &lt;em&gt;TailwindCSS&lt;/em&gt; for styling, &lt;em&gt;MongoDB&lt;/em&gt; for database, &lt;em&gt;NodeJS&lt;/em&gt; + &lt;em&gt;Express&lt;/em&gt; for backend server, routing and communicating with the database and &lt;em&gt;Firebase&lt;/em&gt; for Google Authentication.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Trying to make the switch from frontend/backend to full-stack? Or just looking to have fun and sharpen up on your dev skills? Then come along and join the 5-part series where we go over the planning, coding (and debugging) of a MERN Stack Application from scratch.&lt;/p&gt;

&lt;p&gt;This series is meant to be a beginner-friendly introduction to the MERN stack to devs who are acquainted with React and NodeJS, have worked on the technologies independently but are unable to connect it all together to complete the puzzle to build a full stack application. With ample space to add more functionalities and completely customize the app, upon completing this 5-part tutorial ,you will be confident in your skills to code a complete MERN stack application from scratch and take your dev skills to the next level!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/rohanjsx/build-a-mern-stack-app-in-5-days-day-1-setting-up-the-backend-44fe"&gt;Part 1&lt;/a&gt; &lt;/p&gt;

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