<?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: Gomandev</title>
    <description>The latest articles on DEV Community by Gomandev (@gomandev).</description>
    <link>https://dev.to/gomandev</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%2F367070%2F97679383-1077-411b-8bd7-66c513baedce.JPG</url>
      <title>DEV Community: Gomandev</title>
      <link>https://dev.to/gomandev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gomandev"/>
    <language>en</language>
    <item>
      <title>Deploy Your Project Live On Netlify.</title>
      <dc:creator>Gomandev</dc:creator>
      <pubDate>Wed, 27 Oct 2021 23:42:21 +0000</pubDate>
      <link>https://dev.to/gomandev/deploy-your-project-live-on-netlify-1d2i</link>
      <guid>https://dev.to/gomandev/deploy-your-project-live-on-netlify-1d2i</guid>
      <description>&lt;p&gt;Have you ever wondered how to view your project live from anywhere not just your local machine as a beginner? You are not alone most beginners do that including me. :)&lt;/p&gt;

&lt;p&gt;Today what I will be showing you guys is a way of deploying your project live using &lt;a href="https://www.netlify.com/"&gt;netlify&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is netlify?
&lt;/h3&gt;

&lt;p&gt;Netlify is a cloud platform that allows developers to Build, deploy, and scale modern web projects.&lt;/p&gt;

&lt;p&gt;Now let's get started.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a netlify account
&lt;/h3&gt;

&lt;p&gt;Visit &lt;a href="https://www.netlify.com/"&gt;netlify.com&lt;/a&gt; and click the signup button in the top-left corner of the webpage. There are a bunch of options to signup, but I will recommend signing up with &lt;a href="//github.com"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy your project
&lt;/h3&gt;

&lt;p&gt;After you successfully log in, navigate to the site's page. At the bottom of the page, you will see a section like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DXwdYbWm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wl2i8mxmvwg4x4u2jm7p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DXwdYbWm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wl2i8mxmvwg4x4u2jm7p.png" alt="Image description" width="880" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All you need to do is to drag your project folder into the area and netlify will finish all the work.&lt;/p&gt;

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

&lt;p&gt;Wait for a few minutes for the projects to finish deploying. When that's done let's make the URL more readable by changing the site name. go to the &lt;code&gt;Site Settings&lt;/code&gt; page, under the general tab you will see the &lt;code&gt;Site Details&lt;/code&gt; section, right at the bottom you will find the &lt;code&gt;Change Site Name&lt;/code&gt; button and change it to something like &lt;strong&gt;preview-project&lt;/strong&gt; it can be anything you could remember.&lt;/p&gt;

&lt;p&gt;All good, now visit the site, &lt;a href="https://preview-project.netlify.app/"&gt;https://preview-project.netlify.app&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This tutorial is geared more toward beginners.&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>netlify</category>
      <category>webdev</category>
    </item>
    <item>
      <title>No More Redux Boilerblate Hell.(Redux Toolkit)</title>
      <dc:creator>Gomandev</dc:creator>
      <pubDate>Wed, 20 Oct 2021 12:05:22 +0000</pubDate>
      <link>https://dev.to/gomandev/no-more-redux-boilerblate-hellredux-toolkit-4ji8</link>
      <guid>https://dev.to/gomandev/no-more-redux-boilerblate-hellredux-toolkit-4ji8</guid>
      <description>&lt;p&gt;A moment ago &lt;a class="mentioned-user" href="https://dev.to/yossefmohamed"&gt;@yossefmohamed&lt;/a&gt; asked a question on how can he use Redux and Next.js. Well, developers get intimidated by redux because of its boilerplate code before you get it up and running. But they are actually a really cool tool that makes any redux user’s life easy.&lt;br&gt;
Today what I will be showing you guys is &lt;a href="https://redux-toolkit.js.org/" rel="noopener noreferrer"&gt;Redux Toolkit&lt;/a&gt; with a simple CRUD example using Next.js. It doesn’t matter if you are already familiar with redux or just got started working with redux, this post is for you.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is redux-toolkit?
&lt;/h3&gt;

&lt;p&gt;Redux Toolkit is an opinionated, batteries-included toolset for efficient Redux development. It comes with the most widely used Redux addons out of the box, like Redux Thunk for async logic and Reselect for writing selector functions, so that you can use them right away without having to install them separately.&lt;/p&gt;

&lt;p&gt;Enough for the talk, let’s write some code.&lt;/p&gt;

&lt;p&gt;First, let’s start by scaffolding a basic Next.js Typescript Project with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-next-app redux-toolkit-example --ts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your project root would look like this:&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%2F7ssnq0o1g32tk88r9i7c.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%2F7ssnq0o1g32tk88r9i7c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Let’s start building the UI.
&lt;/h2&gt;

&lt;p&gt;Go to &lt;em&gt;pages/index.js&lt;/em&gt; and replace the default code with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Home() {
  return (
    &amp;lt;div className="conatiner"&amp;gt;
      &amp;lt;div className="list-container"&amp;gt;
        &amp;lt;div className="list-header"&amp;gt;
          &amp;lt;h1 className="title"&amp;gt;
            Lists&amp;lt;span&amp;gt;.&amp;lt;/span&amp;gt;
          &amp;lt;/h1&amp;gt;
          &amp;lt;div className="input-field"&amp;gt;
            &amp;lt;input type="text" className="search" placeholder="Search..." /&amp;gt;
            &amp;lt;button className="btn"&amp;gt;Search&amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div className="list-body"&amp;gt;
          &amp;lt;div className="list-item"&amp;gt;
            &amp;lt;div className="list-item-content"&amp;gt;milk&amp;lt;/div&amp;gt;
            &amp;lt;button className="list-item-footer"&amp;gt;X&amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="list-item"&amp;gt;
            &amp;lt;div className="list-item-content"&amp;gt;sugar&amp;lt;/div&amp;gt;
            &amp;lt;button className="list-item-footer"&amp;gt;X&amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="list-item"&amp;gt;
            &amp;lt;div className="list-item-content"&amp;gt;coffee&amp;lt;/div&amp;gt;
            &amp;lt;button className="list-item-footer"&amp;gt;X&amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="list-item"&amp;gt;
            &amp;lt;div className="list-item-content"&amp;gt;eggs&amp;lt;/div&amp;gt;
            &amp;lt;button className="list-item-footer"&amp;gt;X&amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}


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

&lt;/div&gt;



&lt;p&gt;Then, go to &lt;em&gt;styles/global.css&lt;/em&gt; and replace the code with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;html,
body {
  padding: 0;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
    Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
  background-color: #fafafa;
}

a {
  color: inherit;
  text-decoration: none;
}

* {
  box-sizing: border-box;
}

.conatiner {
  max-width: 700px;
  margin: 0 auto;
}

.list-container {
  display: flex;
  justify-self: center;
  align-self: center;
  flex-direction: column;
  width: 500px;
}

.list-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-header .title {
  font-size: 2rem;
}

.list-header .input-field input {
  margin-right: 1em;
  padding: 8px 10px;
  border-radius: 10px;
  border: #ccc solid 1px;
}

.list-header .input-field button {
  display: inline-block;
  background-color: #78f0f0;
  color: #000;
  border-radius: 10px;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
}

span {
  color: #78f0f0;
}

.list-body {
  width: 100%;
  margin-top: 2em;
}

.list-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1em;
}

.list-item button {
  background-color: #78f0f0;
  color: #000;
  border-radius: 50%;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
}


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

&lt;/div&gt;



&lt;p&gt;Now start the project with yarn or npm depending on the package manager you are using which in my case is npm.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will start the server on &lt;em&gt;localhost:3000&lt;/em&gt;, then open localhost:3000 in your browser and you will see this printed in the webpage:&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%2F480kq26vvdk7kdib9wat.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%2F480kq26vvdk7kdib9wat.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are now done building the UI.&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's dive into redux-toolkit
&lt;/h2&gt;

&lt;p&gt;Let's start by installing required packages:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm i @reduxjs/toolkit react-redux&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When that is done, create a new folder in the root directory call &lt;strong&gt;store&lt;/strong&gt;, then create two files &lt;em&gt;config.js&lt;/em&gt; and &lt;em&gt;rootReducer.js&lt;/em&gt;  in &lt;em&gt;/store&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  rootReducer.js
&lt;/h3&gt;

&lt;p&gt;this is the root of all reducers.&lt;br&gt;
insert this code in &lt;em&gt;rootReducer.js&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { combineReducers } from "@reduxjs/toolkit";
import { listSlice } from "./ducks/list";

const rootReducer = combineReducers({
  list: listSlice.reducer,
});

export default rootReducer;

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

&lt;/div&gt;



&lt;p&gt;What happened here is that I imported a &lt;code&gt;combineReducers()&lt;/code&gt; function from &lt;code&gt;@reduxjs/toolkit&lt;/code&gt;. The &lt;code&gt;combineReducers&lt;/code&gt; helper function turns an object whose values are different reducing functions into a single reducing function you can pass to createStore. We will be having a single reducer, so &lt;code&gt;combineReducers&lt;/code&gt; isn't necessary. But as your app grows more complex, you'll want to split your reducing function into separate functions.&lt;br&gt;
And also import &lt;code&gt;listSlice&lt;/code&gt; which we have not create yet.&lt;/p&gt;
&lt;h3&gt;
  
  
  config.js
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;config.js&lt;/em&gt; is a where we configure our redux toolkit.&lt;br&gt;
insert this code in &lt;em&gt;config.js&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { configureStore } from "@reduxjs/toolkit";
import rootReducer from "./rootReducer";

const store = configureStore({
  reducer: rootReducer,
});

export type AppDispatch = typeof store.dispatch;
export type AppThunk = ThunkAction&amp;lt;void, RootState, unknown, Action&amp;gt;;

export default store;

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

&lt;/div&gt;



&lt;p&gt;We now configure the store using the &lt;code&gt;configureStore&lt;/code&gt; function. &lt;code&gt;configureStore&lt;/code&gt; is a friendly abstraction over the standard Redux createStore function that adds good defaults to the store setup for a better development experience. this function will automatically configure the redux devtools extension, you can also pass optional configuration to the function. to learn more refer to the &lt;a href="https://redux-toolkit.js.org/api/configureStore" rel="noopener noreferrer"&gt;docs&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Slices
&lt;/h3&gt;

&lt;p&gt;Create a directory call &lt;strong&gt;ducks&lt;/strong&gt; with &lt;em&gt;listSlice.js&lt;/em&gt; file in it.&lt;br&gt;
Paste this in &lt;em&gt;listSlice.js&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createSlice } from "@reduxjs/toolkit";

export type listState = {
  list: any[];
};

const initialState: listState = {
  list: ["egg", "milk", "sugar", "coffee"],
};

export const listSlice: any = createSlice({
  name: "list",
  initialState,
  reducers: {
    addList: (state, { payload }) =&amp;gt; void state.list.push(payload),
    removeList: (state, { payload }) =&amp;gt;
      void state.list.splice(state.list.findIndex((item) =&amp;gt; item === payload)),
  },
  extraReducers: {},
});

export const { addList, removeList } = listSlice.actions;

export const listSelector = (state: any) =&amp;gt; state.list;

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

&lt;/div&gt;



&lt;p&gt;Okay we now create our first slice using the &lt;em&gt;createSlice&lt;/em&gt; function that performs two actions and we have our initial &lt;em&gt;list&lt;/em&gt; state with some default items.&lt;/p&gt;

&lt;h3&gt;
  
  
  Back to the UI
&lt;/h3&gt;

&lt;p&gt;To use redux in the UI we need to install the &lt;a href="https://react-redux.js.org/" rel="noopener noreferrer"&gt;react-redux&lt;/a&gt; library.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm i react-redux&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When the installation is done, replace the default code with this in the &lt;em&gt;_app.js&lt;/em&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "../styles/globals.css";

import store from "../store/config";
import { Provider } from "react-redux";

function MyApp({ Component, pageProps }) {
  return (
    &amp;lt;Provider store={store}&amp;gt;
      &amp;lt;Component {...pageProps} /&amp;gt;
    &amp;lt;/Provider&amp;gt;
  );
}

export default MyApp;


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

&lt;/div&gt;



&lt;p&gt;Now that we configure redux in our UI let move to &lt;em&gt;index.tsx&lt;/em&gt; file and Replace it with this updated code:&lt;br&gt;
&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 { useDispatch, useSelector } from "react-redux";
import { addList, listSelector, removeList } from "../store/ducks/list";

export default function Home() {
  const [input, setInput] = useState&amp;lt;string&amp;gt;("");
  const { list } = useSelector(listSelector);
  const dispatch = useDispatch();

  const addItem = () =&amp;gt; {
    dispatch(addList(input));
  };
  const removeItem = (value: string) =&amp;gt; {
    dispatch(removeList(value));
  };
  return (
    &amp;lt;div className="conatiner"&amp;gt;
      &amp;lt;div className="list-container"&amp;gt;
        &amp;lt;div className="list-header"&amp;gt;
          &amp;lt;h1 className="title"&amp;gt;
            Lists&amp;lt;span&amp;gt;.&amp;lt;/span&amp;gt;
          &amp;lt;/h1&amp;gt;
          &amp;lt;div className="input-field"&amp;gt;
            &amp;lt;input
              onChange={(e) =&amp;gt; setInput(e.target.value)}
              type="text"
              className="search"
              placeholder="Add"
            /&amp;gt;
            &amp;lt;button onClick={addItem} className="btn"&amp;gt;
              Add
            &amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div className="list-body"&amp;gt;
          {list &amp;amp;&amp;amp;
            list.map((l: string, index: number) =&amp;gt; (
              &amp;lt;div key={index} className="list-item"&amp;gt;
                &amp;lt;div className="list-item-content"&amp;gt;{l}&amp;lt;/div&amp;gt;
                &amp;lt;button
                  onClick={() =&amp;gt; removeItem(l)}
                  className="list-item-footer"
                &amp;gt;
                  X
                &amp;lt;/button&amp;gt;
              &amp;lt;/div&amp;gt;
            ))}
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}


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

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Note: this is only the minor basic of redux-toolkit but they are a lot more about this library. &lt;br&gt;
Thank you for reading my first tutorial on Dev.to, I hope you learn something from this :).&lt;/p&gt;

</description>
      <category>redux</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What will you change or add in javascript if you have a chance?</title>
      <dc:creator>Gomandev</dc:creator>
      <pubDate>Fri, 27 Aug 2021 19:13:20 +0000</pubDate>
      <link>https://dev.to/gomandev/what-will-you-change-or-add-in-javascript-if-you-have-a-chance-132</link>
      <guid>https://dev.to/gomandev/what-will-you-change-or-add-in-javascript-if-you-have-a-chance-132</guid>
      <description>&lt;p&gt;I was asked this question in an interview sitting a couple of months ago. I'm pretty sure some of you really ever thought of changing something in JS language.&lt;/p&gt;

&lt;p&gt;I will be happy to know your opinion in the comment.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discuss</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to be an up-to-date programmer.</title>
      <dc:creator>Gomandev</dc:creator>
      <pubDate>Tue, 13 Jul 2021 08:26:54 +0000</pubDate>
      <link>https://dev.to/gomandev/how-to-be-an-up-to-date-programmer-lg7</link>
      <guid>https://dev.to/gomandev/how-to-be-an-up-to-date-programmer-lg7</guid>
      <description>&lt;p&gt;Just read posts on Dev.to every morning.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
