<?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: Moszio</title>
    <description>The latest articles on DEV Community by Moszio (@andor).</description>
    <link>https://dev.to/andor</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%2F883155%2Fe5bfbf42-c5fe-44e2-8499-83869c0ecad0.png</url>
      <title>DEV Community: Moszio</title>
      <link>https://dev.to/andor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andor"/>
    <language>en</language>
    <item>
      <title>CSS GRID</title>
      <dc:creator>Moszio</dc:creator>
      <pubDate>Thu, 29 Dec 2022 03:29:51 +0000</pubDate>
      <link>https://dev.to/andor/css-grid-3a26</link>
      <guid>https://dev.to/andor/css-grid-3a26</guid>
      <description>&lt;p&gt;Here we are CSS Grid. I don't know how about you but I am very shaky with Grid. You can do setup in many different ways and all the column rows etc... just gets very confusing at some times and I can't visualize it in my head.&lt;/p&gt;

&lt;p&gt;So I just recently started to learn a way that makes so much sense.&lt;br&gt;
It requires a bit more setup but it will really make it worth it at the end of the day. At least it did for me. As I made this discovery I wanted to share as I was really struggling to get a strong understanding of how to use Grid.&lt;/p&gt;

&lt;p&gt;The magic word is &lt;code&gt;grid-template-areas&lt;/code&gt;. You only have to use this and you will have a beautiful arrangement where you only have to worry about the parent element but not the child. &lt;/p&gt;

&lt;p&gt;Lets imagine we want to build this grid. (of course responsive in todays world)&lt;/p&gt;

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

&lt;p&gt;Before you would use &lt;em&gt;grid columns, rows, heights, spans etc&lt;/em&gt; to have this not so complicated display it was hard to wrap your head around it.&lt;/p&gt;

&lt;p&gt;now with grid-template-areas I think it makes a lot more sense.&lt;/p&gt;

&lt;p&gt;our boxes will have simple setup with a class name &lt;strong&gt;box&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box {
  border: 2px solid black;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes, no height, no width, no nothing :D!!!!!&lt;/p&gt;

&lt;p&gt;and the area where our 5 boxes will live is going to be called &lt;strong&gt;box-grid&lt;/strong&gt;&lt;br&gt;
we will give it the following specifications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box-grid {
  display: grid;
  width: min(95%, 70rem);
  height: 100vh;
  margin-inline: auto;
  padding-block: 2rem;
  gap: 1.5rem;
  grid-auto-columns: 1fr;
  grid-template-areas:
    'one'
    'two'
    'three'
    'four'
    'five';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes it is a bit strange. It has to be string and just like above the way you give the value to &lt;code&gt;grid-template-areas&lt;/code&gt; is as many rows you want you will place the areas under each other. so lets say I want to have in this case 5 boxes on top of each other. Then the above syntax will have to be done.&lt;br&gt;
Now if you leave it just this way will not do a lot.&lt;br&gt;
You have to define which is 'one', 'two', 'three', 'four', 'five'.&lt;br&gt;
Here is how to do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box:nth-child(1) {
  grid-area: one;
}
.box:nth-child(2) {
  grid-area: two;
}
.box:nth-child(3) {
  grid-area: three;
}
.box:nth-child(4) {
  grid-area: four;
}
.box:nth-child(5) {
  grid-area: five;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the &lt;code&gt;nth-child(number)&lt;/code&gt; you will basically select the children in this case the box classes and you tell each one of them which name they will listen to. &lt;/p&gt;

&lt;p&gt;Now if you check your display everything should be on top of each other and will take up all the space they have in the parent element which if &lt;strong&gt;box-grid&lt;/strong&gt;.&lt;br&gt;
This is amazing but we don't have our design ready yet. So far simple, now the best part comes. How this will be responsive. Lets say we want to give a specific layout to different screen sizes. &lt;br&gt;
It is super simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
@media (min-width: 30em) {
  .box-grid{
    grid-template-areas:
      'one two'
      'one three'
      'four four'
      'five five';
  }
}


@media (min-width: 50em) {
  .box-grid{
    grid-template-areas:
      'one two two three'
      'one four five five';
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the help of &lt;code&gt;@media&lt;/code&gt; query and the names we have defined above (one, two, three, four, five) you basically tell CSS at what breakpoints should those boxes be display in what specific way. &lt;br&gt;
In my example at &lt;/p&gt;

&lt;p&gt;breakpoint 30em:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;4 rows&lt;/li&gt;
&lt;li&gt;2 columns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;breakpoint 50em:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2 rows&lt;/li&gt;
&lt;li&gt;4 columns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's it. You don't  have to worry about box sizes or gaps or auto margins or anything as grid will just populate whatever space it has in the parent element, based on your grid-template-areas.&lt;/p&gt;

&lt;p&gt;I hope this helps to understand grid in a bit more straight forward way. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Next.js custom API</title>
      <dc:creator>Moszio</dc:creator>
      <pubDate>Mon, 31 Oct 2022 16:47:52 +0000</pubDate>
      <link>https://dev.to/andor/nextjs-custom-api-f4l</link>
      <guid>https://dev.to/andor/nextjs-custom-api-f4l</guid>
      <description>&lt;p&gt;Custom API with Next.js&lt;/p&gt;

&lt;p&gt;Continuing my previous Next.js article. I wanted to post a smaller section about creating your custom API. &lt;br&gt;
It is very simple and only requires a few steps so you can create your own API and make some of your pages more dynamic.  &lt;/p&gt;

&lt;p&gt;Let's say in our case we create a file with random data and this data can be fetched within our application. &lt;br&gt;
Of course you could use external sources too like SQL etc. but for now I just make my own database with JS.&lt;/p&gt;

&lt;p&gt;We start we creating a JS file called &lt;code&gt;data.js&lt;/code&gt; in the main folder.&lt;br&gt;
(assuming you have some structure already and you start your application based on my previous blog).&lt;br&gt;
We can add any data in here. but I just place something random for now.&lt;br&gt;
My folder will have an array of object. Ensure what ever data will be placed in here the objects need to have an id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const projects = [
  {
    id: '1',
    title: 'Project1',
    description: 'Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae beatae ullam est voluptatum voluptatem incidunt accusantium dicta ad? Quasi necessitatibus at maiores sunt? Doloribus odit, expedita aliquam eius harum ipsa!',
    link: 'https://github.com/SomeonesGithub',
  },
  {
    id: '2',
    title: 'Project2',
    description: 'Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae beatae ullam est voluptatum voluptatem incidunt accusantium dicta ad? Quasi necessitatibus at maiores sunt? Doloribus odit, expedita aliquam eius harum ipsa!',
    link: 'https://github.com/SomeonesGithub',
  },
  {
    id: '3',
    title: 'Project3',
    description: 'Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae beatae ullam est voluptatum voluptatem incidunt accusantium dicta ad? Quasi necessitatibus at maiores sunt? Doloribus odit, expedita aliquam eius harum ipsa!',
    link: 'https://github.com/Moszio/Meal-Randomizer-App',
  },
]

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

&lt;/div&gt;



&lt;p&gt;Ones this is done we can move to the next step. &lt;br&gt;
In your pages folder you can find an other folder called &lt;code&gt;api&lt;/code&gt; created an other folder within &lt;code&gt;api&lt;/code&gt; and add a new file called &lt;code&gt;index.js&lt;/code&gt;. You might have a premade file in there so lets just delete it for now. &lt;/p&gt;

&lt;p&gt;in you index.js we will do 2 things first importing in your data.js file and we create a function that will handle this data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { projects } from '../../../data'

const handler = (req, res) =&amp;gt; {
  res.status(200).json(projects)
}

export default handler

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

&lt;/div&gt;



&lt;p&gt;in our function we pass in the req, res which will be the request and response we are fetching and parsing to json.&lt;br&gt;
Ones that is done. You can direct to your url and call this data.&lt;br&gt;
In my case it will be &lt;a href="http://localhost:3000/api/projects"&gt;http://localhost:3000/api/projects&lt;/a&gt;&lt;br&gt;
and there you go you should see your custom api data in your browser.&lt;/p&gt;

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

&lt;p&gt;Now that we have access to all the data. We want to be more specific and only get 1 particular object. This is when id can also come in handy.&lt;/p&gt;

&lt;p&gt;Right now if you go to your URL and try to select one of your object with their ID it will throw out an error.&lt;br&gt;
&lt;a href="http://localhost:3000/api/projects/1"&gt;http://localhost:3000/api/projects/1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix that we will create a new file in the same &lt;code&gt;api&lt;/code&gt; folder.&lt;br&gt;
It will have the following naming convention: &lt;code&gt;[id].js&lt;/code&gt; the bracket notation is essential to ensure our route is dynamic.&lt;/p&gt;

&lt;p&gt;Ones you are in this file lets add the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { projects } from '../../../data'

const idPointer = ({ query: { id } }, res) =&amp;gt; {
  const filtered = projects.filter((project) =&amp;gt; project.id === id)

  if (filtered.length &amp;gt; 0) {
    res.status(200).json(filtered[0])
  } else {
    res.status(404).json({ message: `The selected id: ${id} not found!` })
  }
}

export default idPointer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again the data from our data.js file was imported and we create our function that will send a request and response. In our case we destructured the id or you could have done just with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;re.query.id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second part of the code is just to ensure if there is an item the data will be returned, but if there is no matching id with the number given in URL then it returns a custom error message.&lt;br&gt;
Make sure to save everything and now you can select API with their id in url.&lt;br&gt;
&lt;a href="http://localhost:3000/api/projects/1"&gt;http://localhost:3000/api/projects/1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or if your try something like 6&lt;br&gt;
&lt;a href="http://localhost:3000/api/projects/6"&gt;http://localhost:3000/api/projects/6&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;it will throw out an error.&lt;/p&gt;

&lt;p&gt;Hope this blog was helpful in your future custom API creation.&lt;/p&gt;

&lt;p&gt;Thank you for reading this.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Next.js</title>
      <dc:creator>Moszio</dc:creator>
      <pubDate>Thu, 20 Oct 2022 16:47:29 +0000</pubDate>
      <link>https://dev.to/andor/nextjs-4hdg</link>
      <guid>https://dev.to/andor/nextjs-4hdg</guid>
      <description>&lt;p&gt;Recently I started interning at a Startup and they are using Next.js, which I have not used before but I have been working and gained some experience with React. React is a base requirement to learn Next.js. You might be able to start right away with Next.js, but for a better understanding starting with React is the right way to go.&lt;br&gt;
Here I wanted to share my first experience and some of the basics I learned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next.js a React Framework for Production.&lt;/strong&gt;&lt;br&gt;
Creating you next.js application:&lt;br&gt;
&lt;code&gt;npx create-next-app name-of-your-app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Starting the server:&lt;br&gt;
&lt;code&gt;npm run dev&lt;/code&gt;&lt;br&gt;
In your browser:&lt;br&gt;
&lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;&lt;br&gt;
Now you should see a basic webpage.&lt;/p&gt;

&lt;p&gt;One of the perks of Next.js is you don't have to use a 3rd party router like in React.js (react-router-dom).&lt;/p&gt;

&lt;p&gt;Simply put your pages in your pages folder. The pages are react components.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Router *&lt;/em&gt;&lt;br&gt;
create a file in your pages folder. &lt;em&gt;Page.js&lt;/em&gt;&lt;br&gt;
in your &lt;em&gt;Page.js&lt;/em&gt; file add the following. Just like you would create a react component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const page = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Page 1&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Keep your pages lower case and for your future components uppercase"&lt;/p&gt;

&lt;p&gt;If you direct your browser to the following:&lt;br&gt;
&lt;a href="http://localhost:3000/page"&gt;http://localhost:3000/page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have your new end point and you are able to see whatever that page contains in this case just a simple Page 1 message.&lt;br&gt;
As simple as that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding title to your page&lt;/strong&gt;&lt;br&gt;
If you learned React. You would have to add this to your public/index.js file in react, but since we don't have it in Next.js we just simply add it to your index.js in page folder.&lt;/p&gt;

&lt;p&gt;(note: in this folder I removed everything except the div)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from 'next/head'

export default function Home() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;Head&amp;gt;
        &amp;lt;title&amp;gt; My site&amp;lt;/title&amp;gt;
        &amp;lt;meta name='keywords' content='website' /&amp;gt;
      &amp;lt;/Head&amp;gt;

      &amp;lt;h1&amp;gt;Welcome to next&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have a title to your page. You can repeat that to all your pages and it will dynamically change the title for all your pages.&lt;br&gt;
Ensure you to import&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from 'next/head'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Styling your page using style components. &lt;br&gt;
In this step we will create a folder called "components" in the main folder (not within pages) and within that file lets create a Layout file. &lt;br&gt;
Here we will import our css style component.&lt;br&gt;
You might see there are already 2 files lets rename the Home.module.css to Layout.module.css&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 from '../styles/Layout.module.css'

const Layout = ({ children }) =&amp;gt; {
  return (
    &amp;lt;div className={styles.container}&amp;gt;
      &amp;lt;main className={styles.main}&amp;gt;{children}&amp;lt;/main&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default Layout


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

&lt;/div&gt;



&lt;p&gt;To reference already existing styles we use the styles.name-of-style as seen above.&lt;/p&gt;

&lt;p&gt;App.js file &lt;br&gt;
This file will be something like a Navbar in React. Whatever you put in here like header, footer etc. will appear on every page.&lt;/p&gt;

&lt;p&gt;Lets import our Layout component to app.js.&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 Layout from '../components/Layout'
function MyApp({ Component, pageProps }) {
  return (
    &amp;lt;Layout&amp;gt;
      &amp;lt;Component {...pageProps} /&amp;gt;
    &amp;lt;/Layout&amp;gt;
  )
}

export default MyApp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "children" in this case will be the content you have added to your pages.(Page 1, Welcome to next, etc.) children will dynamically change that content based on what endpoint you are on.&lt;br&gt;
You can also add other content to your Layout component to, if you add it to this file it will appear on all your pages. Give it a try like adding an h1 with any message. You will see that message on all pages with addition to the page content. In our case we will add a navbar.&lt;/p&gt;

&lt;p&gt;As a next step we will create our actual Navbar that is going to reside on top of our page and it will be visible on every page.&lt;/p&gt;

&lt;p&gt;create in your styles folder a Navbar.modules.css (modules will need to be added if you just want this CSS to be applied to that specific component.&lt;br&gt;
We will add some CSS to this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.nav {
  height: 60px;
  padding: 15px;
  background-color: rgb(255, 119, 119);
  color: rgb(0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.nav ul {
  display: flex;
  justify-content: center;
  align-items: center;
  list-style: none;
}

.nav ul li a {
  margin: 5px 15px;
  font-size: 25px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create in component folder Navbar.js then add the following.&lt;/p&gt;

&lt;p&gt;On top we will import our newly created Navbar.modules.css file for styling purposes. when you import it you can name it whatever name you want it navStyle just make sure you use appropriate naming convention for readability. &lt;/p&gt;

&lt;p&gt;We will also import Link just like in react router for guiding through our endpoints. &lt;/p&gt;

&lt;p&gt;Ones everything is imported add the ul, li elements and within our li we also add the Link tag for the routing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import navStyles from '../styles/Navbar.module.css'
import Link from 'next/link'

const Navbar = () =&amp;gt; {
  return (
    &amp;lt;nav className={navStyles.nav}&amp;gt;
      &amp;lt;ul&amp;gt;
        &amp;lt;li&amp;gt;
          &amp;lt;Link href='/'&amp;gt; Home &amp;lt;/Link&amp;gt;
        &amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;
          &amp;lt;Link href='/page'&amp;gt; Page &amp;lt;/Link&amp;gt;
        &amp;lt;/li&amp;gt;
      &amp;lt;/ul&amp;gt;
    &amp;lt;/nav&amp;gt;
  )
}

export default Navbar

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

&lt;/div&gt;



&lt;p&gt;Ones that's done we just have to import this component into our Layout file and add it outside your div. so it will always be the same on every page regardless of the content.&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 from '../styles/Layout.module.css'
import Navbar from './Navbar'

const Layout = ({ children }) =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;Navbar&amp;gt;&amp;lt;/Navbar&amp;gt;
      &amp;lt;div className={styles.container}&amp;gt;
        &amp;lt;main className={styles.main}&amp;gt;{children}&amp;lt;/main&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  )
}

export default Layout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you should see your navbar on top and you can navigate between your pages.&lt;/p&gt;

&lt;p&gt;This is it you have a Next.js basic Website with a navbar and routing. &lt;/p&gt;

&lt;p&gt;Hope you enjoyed it.&lt;/p&gt;

&lt;p&gt;If you need, there are several courses on youtube or you can use the Next.js documentation for additional information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/docs"&gt;https://nextjs.org/docs&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Redux for beginners</title>
      <dc:creator>Moszio</dc:creator>
      <pubDate>Sun, 16 Oct 2022 13:53:48 +0000</pubDate>
      <link>https://dev.to/andor/redux-for-beginners-5814</link>
      <guid>https://dev.to/andor/redux-for-beginners-5814</guid>
      <description>&lt;p&gt;I am in the middle of my project and I have been experimenting with REDUX recently. It was very intimidating to me at first so I wanted to share a small guide to sum up the most important things and to explain it in a very simple way. I hope it helps others.&lt;/p&gt;

&lt;p&gt;Little about me I am a beginner Software Engineer so there might be better ways to do this or you can find cleaner code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is Redux good?&lt;/strong&gt;&lt;br&gt;
Well basically you know how you have to pass down your states and props in React to use them in your components. Sometimes you have to pass it down to more then 1 component so it can be a bit of a pain. Redux helps you to access those functions/states in any component.&lt;/p&gt;

&lt;p&gt;The following  guide is based on a basic Counter Application.&lt;/p&gt;
&lt;h2&gt;
  
  
  A step by Step guide to Redux Basics
&lt;/h2&gt;

&lt;p&gt;Very first thing setting up Redux:&lt;br&gt;
create your react app:&lt;br&gt;
&lt;code&gt;npx create-react-app counter&lt;/code&gt;&lt;br&gt;
cd into you react app&lt;br&gt;
in your terminal:&lt;br&gt;
&lt;code&gt;npm install redux&lt;/code&gt;&lt;br&gt;
&lt;code&gt;npm install react-redux&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There are 4 sections with Redux(&lt;em&gt;at least what I know so far&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Sections:&lt;br&gt;
&lt;strong&gt;REDUCER&lt;/strong&gt; - pretty much your functions/states&lt;br&gt;
&lt;strong&gt;STORE&lt;/strong&gt; - your globalized state(this is what you will pass down to all your components so you can use your function anywhere)&lt;br&gt;
&lt;strong&gt;ACTIONS&lt;/strong&gt; - this will help you use the functions (&lt;em&gt;like increment/decrement/changing true/ false etc.&lt;/em&gt;(&lt;br&gt;
&lt;strong&gt;DISPATCH&lt;/strong&gt; - to dispatch your actions&lt;/p&gt;

&lt;p&gt;Of course under the hood there is lot more happening but again I just want to provide a simple guide.&lt;/p&gt;

&lt;p&gt;/////////////////////////////////////////////////////////////&lt;br&gt;
&lt;strong&gt;Step 1.&lt;/strong&gt; &lt;br&gt;
first setup files and folders&lt;br&gt;
in src folder create:&lt;br&gt;
actions folder&lt;br&gt;
reducer folder&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt;&lt;br&gt;
in action folder create:&lt;br&gt;
index.js&lt;br&gt;
in reducer folder create: &lt;br&gt;
index.js&lt;br&gt;
counter.js&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt;&lt;br&gt;
in counter.js file &lt;/p&gt;

&lt;p&gt;REDUCER:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const counterReducer = (state = 0, action) =&amp;gt; {
  switch(action.type){
    case "INCREMENT":
      return state + action.payload;
    case "DECREMENT":
      return state - 1
    default:
        return 0
  }
};
export default counterReducer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have multiple reducers a combiner can be used &lt;br&gt;
Before using combiner import it from redux library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import counterReducer from "./counter";
import { combineReducers } from "redux";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;all reducers need to be imported to the combiner file in this case index.js in reducer folder.&lt;/p&gt;

&lt;p&gt;Now that the Reducer is setup &lt;br&gt;
We can move to next section which is Store&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt;&lt;br&gt;
In this step we will work in the src/index.js file.&lt;br&gt;
To start with lets import hooks and files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createStore } from 'redux';
import allReducers from './reducers/index.js'
import { Provider } from 'react-redux';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after the import is added:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const store = createStore(
  allReducers,
  window.__REDUX_DEVTOOLS_EXTENSION__ &amp;amp;&amp;amp; window.__REDUX_DEVTOOLS_EXTENSION__()
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the store is created the allReduces file we created earlier will be added and an other line of code which basically allow you to check your work in the Dev Tools, otherwise you would have to work blindly.&lt;/p&gt;

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

&lt;p&gt;The last thing needs to be setup in our current file is the Provider imported earlier.&lt;br&gt;
Wrap your App component with the provider as follows.&lt;br&gt;
Then pass the store variable to the Provider hook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
&amp;lt;Provider store={store}&amp;gt;
  &amp;lt;React.StrictMode&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/React.StrictMode&amp;gt;
  &amp;lt;/Provider&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;br&gt;
ACTIONS&lt;/p&gt;

&lt;p&gt;in you action/index.js file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const increment = (number) =&amp;gt; {
    return {
        type : 'INCREMENT',
        payload: number
    }
}
export const decrement = () =&amp;gt; {
    return {
        type : 'DECREMENT'
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;br&gt;
Final Step&lt;br&gt;
**&lt;/p&gt;

&lt;p&gt;in you App.js filer&lt;br&gt;
import hooks and files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useSelector, useDispatch } from "react-redux";
import { increment, decrement } from "./actions";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;useSelector will allow you to set the state of and display or use the result of that function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const counter = useSelector(state =&amp;gt; state.counter)
const dispatch = useDispatch()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the dispatch variable we can finally add functionality to our counter button. and the counter variable will keep track of the total of our counter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Counter {counter}&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; dispatch(increment(5))}&amp;gt;+&amp;lt;/button&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; dispatch(decrement())}&amp;gt;-&amp;lt;/button&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; dispatch(signIn())}&amp;gt;Change state&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We could also add other functionality with reducers like filter or true false statement and create conditional statements when logging in.&lt;/p&gt;

&lt;p&gt;This got a little longer then expected but it should sum up the basics.&lt;br&gt;
Hope this helps.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>&lt;h1&gt;Phase 1 Flatiron School experience and suggestions!&lt;h1&gt;</title>
      <dc:creator>Moszio</dc:creator>
      <pubDate>Fri, 05 Aug 2022 22:51:42 +0000</pubDate>
      <link>https://dev.to/andor/phase-1-flatiron-school-experience-and-suggestions-5c4j</link>
      <guid>https://dev.to/andor/phase-1-flatiron-school-experience-and-suggestions-5c4j</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
I just finished my 6th week at Flatiron School. Time flies by... Just before entering phase-3 I wanted to share my experience and progress and some suggestions to anyone who is thinking to get started!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 1&lt;/strong&gt;&lt;br&gt;
Oh week one... the best word to describe it? Overwhelming.. Not only you have a whole new environment and new people, but you have to go through an immense amount of material. I was studying day and night with very little sleep, but I got through it and learned so much. I really started to love JavaScript as it was our main focus. There are just so much you can do with it.&lt;br&gt;
My favorite of all is by far event listeners. There is nothing more rewarding then to see your buttons working and actually functioning. &lt;br&gt;
Of course, there is a lot more then just event listeners to it.&lt;br&gt;
My suggestion for anyone who decides to start this school? Be prepared learn some basics. Definitely learn some HTML and CSS because you are not going to have time to learn from scratch while you are learning JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 2&lt;/strong&gt;&lt;br&gt;
Week 2 was for me deepening my knowledge about JavaScript get to know CRUD operations such as GET,POST,PATCH,DELETE.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let request = async () =&amp;gt; {
 // initiate request to your choosen server
 let req = await fetch(`url`)
 let res = await req.json()
 console.log("data: ", res)
}
request()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using an external API or a local host allows you to have more persistent websites and not just have everything erased after you refresh the page. The best thing about the API is the data it will provide you and you can build so much around that data.&lt;br&gt;
Somehow coming up with a new website idea is a lot easier. Just lookup public APIs and you can build anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 3&lt;/strong&gt;&lt;br&gt;
It starts to feel like everything is coming together...&lt;br&gt;
This is also the week of creating your own website as your first project.&lt;br&gt;
When I first started to think about a website idea my first thought to get motivation is looking through public API-s, although it is a great way to get motivation there is just way too many options and you could feel like in candy store... Good luck making up your mind. You just want to try all of them.&lt;br&gt;
So I decided to move away from creating my website based on API  and instead I focused on my previous experiences and what am I passionate about. So I did and I have created something that I could call my own, what a great feeling. &lt;br&gt;
**Suggestion **make sure whatever your idea is, before deep diving into coding first find a relevant API that provides you the necessary data.&lt;/p&gt;

&lt;p&gt;Here is a list of API(no authorization required):&lt;br&gt;
&lt;a href="https://mixedanalytics.com/blog/list-actually-free-open-no-auth-needed-apis/"&gt;https://mixedanalytics.com/blog/list-actually-free-open-no-auth-needed-apis/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just one more link to share:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/"&gt;https://developer.mozilla.org/en-US/&lt;/a&gt;&lt;br&gt;
this website will become your best friend:)&lt;/p&gt;

&lt;p&gt;If you are interested to get more information about the school and the program don't hesitate to DM me.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>parseInt()!</title>
      <dc:creator>Moszio</dc:creator>
      <pubDate>Fri, 15 Jul 2022 14:51:28 +0000</pubDate>
      <link>https://dev.to/andor/parseint-7ol</link>
      <guid>https://dev.to/andor/parseint-7ol</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The reason behind choosing this particular topic? As a student at Flatiron School we go through many challenges and many time you come across a challenge that requires you to google. I still have a lot to improve on my googling skills. See here comes in the choice of my topic. I just could not find the answer to this very simple question. I tried so many ways and even though you can find some answer they just seemed way to difficult.&lt;/p&gt;

&lt;p&gt;"The challenge"&lt;br&gt;
In that particular challenge you had to add a vote based on the value of your input field to your total vote count.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   &amp;lt;h4&amp;gt;Total Votes: &amp;lt;span id="vote-count"&amp;gt;Character's Votes&amp;lt;/span&amp;gt;&amp;lt;/h4&amp;gt;;
        &amp;lt;form id="votes-form"&amp;gt;;
          &amp;lt;input type="text" placeholder="Enter Votes" id="votes" name="votes" /&amp;gt;;
          &amp;lt;input type="submit" value="Add Votes" /&amp;gt;;
        &amp;lt;/form&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is nothing too complicated right? Well the answer was not so straight forward. Since the input is a string it will not be able to cumulate your votes.&lt;/p&gt;

&lt;p&gt;This is when parseInt() comes useful.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; let count = 0;
 count =  parseInt(input.value) + count;
   characterVote.textContent = count;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function will return an integer from the string argument and from now it will be able to cumulate your total count.&lt;/p&gt;

&lt;p&gt;Hope this was useful! Feel free to reach out if you have or had the same struggle with parseInt() and strings :D.&lt;/p&gt;

&lt;p&gt;Also here is a link to more information about parseInt():&lt;/p&gt;

&lt;p&gt;MDN web docs_:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
