<?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: Pavol Ďuďák</title>
    <description>The latest articles on DEV Community by Pavol Ďuďák (@dudakp).</description>
    <link>https://dev.to/dudakp</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%2F123415%2F787902d7-c6e0-4b6a-abd4-77067bf5a99d.png</url>
      <title>DEV Community: Pavol Ďuďák</title>
      <link>https://dev.to/dudakp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dudakp"/>
    <language>en</language>
    <item>
      <title>My take on Redux</title>
      <dc:creator>Pavol Ďuďák</dc:creator>
      <pubDate>Tue, 03 Sep 2019 17:14:04 +0000</pubDate>
      <link>https://dev.to/dudakp/my-take-on-redux-2289</link>
      <guid>https://dev.to/dudakp/my-take-on-redux-2289</guid>
      <description>&lt;p&gt;After really awesome React and Redux training at work, I’ve decided to create one simple app to solidify my newly acquired knowledge about React and (mainly) Redux and during development, I’ve come across reducer that was starting to be poorly readable (at least for me) so here’s my take on this problem.&lt;br&gt;
Maybe it’s not that bad but I wanted something simpler and more readable.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Klk7rp3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rklkcps9xts2c4yl2kw1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Klk7rp3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rklkcps9xts2c4yl2kw1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
First of all, ...state at the beginning of every case, I don’t want that but, you can’t get rid of that but you can replace it (well we can get rid of only the … spread operator)! Still, you will be writing something in every case. Can’t we make it just a one-ist function call?&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--67M-3FsI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fcu0eqetmpo0ctp7xwql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--67M-3FsI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fcu0eqetmpo0ctp7xwql.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
This will replace object creation in return, we just call this function like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dBcO54qk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vczjkj70311v4a1k9tv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dBcO54qk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vczjkj70311v4a1k9tv6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
{ breed: payload } is OK but something with more fields can become less readable. &lt;br&gt;
Just make something like createState.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rbhsAccO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/apgafbtag9fd3q4fuijs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rbhsAccO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/apgafbtag9fd3q4fuijs.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
This will replace FETCH_PICTURES_SUCCESS with just &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mcQ60_X_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/twdq27m0hbqsg8l0445o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mcQ60_X_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/twdq27m0hbqsg8l0445o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
and the reducer becomes more just function calls.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iGqXD-zG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ft1q79db8rlmxur7f74u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iGqXD-zG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ft1q79db8rlmxur7f74u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Let’s take one more example. I’ve had this piece od code in my reducer&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JEWwIDSh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/42efwy8wgd9w80255h9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JEWwIDSh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/42efwy8wgd9w80255h9u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
and I don’t want that in my reducer, put it in state creator! &lt;br&gt;
Using this pattern I’ve ended up with really clean reducer and file with functions that I call state creators separated in their own file.&lt;/p&gt;

&lt;p&gt;If you are interested here is the app I've made (code is on prod branch).&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/dudakp"&gt;
        dudakp
      &lt;/a&gt; / &lt;a href="https://github.com/dudakp/dogBoard"&gt;
        dogBoard
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      just dogs
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
dogBoard&lt;/h1&gt;
&lt;p&gt;just dogs&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/dudakp/dogBoard"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;&lt;a href="https://goofy-fermi-c0f561.netlify.com/"&gt;Here is Netlify link for live app&lt;/a&gt; it's just infinite dog pictures. Nothing special just something for me to practice react and redux.&lt;br&gt;
Let me know what you think about this pattern :) &lt;br&gt;
Love to see any kind criticism :)&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What hides under JSX</title>
      <dc:creator>Pavol Ďuďák</dc:creator>
      <pubDate>Tue, 27 Aug 2019 16:56:45 +0000</pubDate>
      <link>https://dev.to/dudakp/what-hides-under-jsx-4bj8</link>
      <guid>https://dev.to/dudakp/what-hides-under-jsx-4bj8</guid>
      <description>&lt;p&gt;I finally pushed myself to write next post so, here it is.&lt;/p&gt;

&lt;p&gt;So, JSX. A really familiar, simple and handy thing for writing components in React. But markup in JS? Kinda weird no? Well, it’s not markup but valid JS expressions, after transpilation just function calls that evaluates to objects, objects representing React components. Let’s grab a simple component:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Just a simple picture frame for grid gallery. The first thing you will probably notice is className. In HTML it’s just class but here, because naming conflict with JS class keyword it is className. All attributes are in camelCase in JSX.&lt;br&gt;
JSX is only expressions remember? That is one of the reasons why camelCase is used. Let’s move on. &lt;br&gt;
One really important thing to remember for components is to return only ONE React element. Here  &lt;em&gt;img&lt;/em&gt; tag is enclosed within &lt;em&gt;div&lt;/em&gt; tag. &lt;br&gt;
In bigger components where you need to return multiple tags (components) the React approach is to enclose elements in &lt;em&gt;React.Fragment&lt;/em&gt; tag or shorter version just empty tag. React will notify you about this if you don't do it. It prevents appending redundant tags in DOM that can sometimes produce invalid HTML. &lt;br&gt;
But how is JSX just JS expressions? You can write the same JSX just like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And this is what transpiler does to our JSX. Just transforms it into this so it can be appended to virtual DOM, but that is a whole other topic.&lt;br&gt;
You can see how ugly nested and verbose can components get without JSX.  As in the first snippet when we are setting src in &lt;em&gt;img&lt;/em&gt; tag prop pic is enclosed in { curly braces }. All JS expressions in JSX must be enclosed in { curly braces } so React can tell what to render and what to evaluate as JS. Probably the last thing is that as in the previous sentence I’ve said “All JS expressions” emphasis on expression. You can’t use if statement, for or while loops in JSX. But, we can substitute if statements with ternary expressions and since glorious ES6 loops with calling map, forEach, etc. on arrays.  Heres an example of map function and usage of our first component:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Somewhere where this snippet lives we have an array of objects including links to dog pictures called ‘doggos’. We are calling map function on this array (which as you probably know iterates through the array and applies provided a function on every element and returns new array). The returns part is important since in JSX we are using only expressions that evaluate to something in our case a new array containing React components.&lt;br&gt;
I hope that my explanation vas understandable and maybe can help someone to better understand React. Also, any questions are welcome.&lt;br&gt;
Thank you for getting to the end of this post. You can suggest in the comments what you want next :)&lt;/p&gt;

</description>
      <category>react</category>
      <category>jsx</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Simple CSS animated loading icon</title>
      <dc:creator>Pavol Ďuďák</dc:creator>
      <pubDate>Wed, 31 Jul 2019 10:38:51 +0000</pubDate>
      <link>https://dev.to/dudakp/simple-css-animated-loading-icon-5f0o</link>
      <guid>https://dev.to/dudakp/simple-css-animated-loading-icon-5f0o</guid>
      <description>&lt;p&gt;Hello! &lt;br&gt;
I've recently got my first real programming job as a junior programmer and I'm still learning various thing along the way. Also, some time ago I have started thinking about writing some blog post to this site so here is my first attempt :)&lt;/p&gt;

&lt;p&gt;For my first post, I've wanted to write about something simple so there is less space for me to make mistake :) so I've made a simple animated loading icon with CSS.&lt;/p&gt;

&lt;p&gt;Here is codepen:&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/dudakp/embed/dxWQYM?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The animation is based on keyframes as you can see. &lt;br&gt;
Basically,I'm just scaling and rotating html element and infinitely looping animation with alternating direction with means that keyframe animation is played forwards and then backward with ease-in-out timing function that sets the speed of the animation. The ease-in-out timing function plays animation starting and ending slowly. For example, if I've used ease-in function the animation will start slowly.&lt;/p&gt;

&lt;p&gt;Any feedback positive or negative is highly appreciated! :) I'm looking forward to write about more stuff I've learned (including Spring, React and maybe Angular)&lt;/p&gt;

&lt;p&gt;Thank you for reading :)&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
