<?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: Kevin Dutzy</title>
    <description>The latest articles on DEV Community by Kevin Dutzy (@keffdu).</description>
    <link>https://dev.to/keffdu</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%2F974579%2F9f25569b-53d8-48a9-9d42-928f50a502cb.png</url>
      <title>DEV Community: Kevin Dutzy</title>
      <link>https://dev.to/keffdu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/keffdu"/>
    <language>en</language>
    <item>
      <title>Create a dynamic route for search bar</title>
      <dc:creator>Kevin Dutzy</dc:creator>
      <pubDate>Thu, 16 Feb 2023 19:09:37 +0000</pubDate>
      <link>https://dev.to/keffdu/create-a-dynamic-route-for-search-bar-10n8</link>
      <guid>https://dev.to/keffdu/create-a-dynamic-route-for-search-bar-10n8</guid>
      <description>&lt;p&gt;Recently I created a project that allowed users to choose from multiple different options to search by (name, brand, type, size), and when creating routs in the backend - I thought there must be a cleaner more efficient way to do this rather than having a separate method for each search type. After thinking if over I realized that through params, I had the ability to pass in the value of both the search type as well as the value of the search, and use those within my method to create a dynamic search that would return the desired results. I'll go ahead and walk through the steps of setting someting like this up in both the front end and back end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the back end
&lt;/h2&gt;

&lt;p&gt;to start, you'll want to create a 'get' route that will be targeting your desired controller where the method will live. something like this&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;get '/:option/:search', to:'synth_modules#search'&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;from there, you need to set up a method in your controller that will be looking to find a specific instance, based on the provided info from params. it might look something like this :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ff61ah4nxtn05o27cfcy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ff61ah4nxtn05o27cfcy5.png" alt=" " width="800" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in the above image - I'm declaring a variable that will be assigned the instance that matches the search. if a instance is created, it will return that data as json back to the front end, and if not the error will be sent up. As you can see, im using a custom method &lt;code&gt;.filtered_synths&lt;/code&gt; and passing in the params to that method, it makes things cleaner in my opinion to have a single method called rather than &lt;code&gt;.where&lt;/code&gt;'s and other methods flying around. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Front End
&lt;/h2&gt;

&lt;p&gt;now that the back end is set up to receive data from the front end, heres how we would set up our fetch request in a react front end. &lt;/p&gt;

&lt;p&gt;first, have a form built out based on your own needs, mine had a drop-down where users can select which attribute they would like to search by, followed by a text box where the search value would go. Each of those values are set to state, so that I can reference that in my fetch URL, and it can stay updated on each change of the form. Once the submit button is clicked, it triggers a fetch request, that looks like this &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fnuyrsaejqg719pwv253x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fnuyrsaejqg719pwv253x.png" alt=" " width="800" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;as you can see you need to interpolate the state values of 'option' as well as 'search' inside the URL, and with the response, set that return object to the state that is rendering all of your cards, in my case is was all synth modules, so now the only objects that will be rendered are the modules that match the search value. &lt;/p&gt;

&lt;p&gt;There are plenty of ways to execute this solution, but at the time this seemed like a efficient way to minimize code and multiple methods, by combining all searches into one method with the powerful use of params. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using React H5 Audio Player</title>
      <dc:creator>Kevin Dutzy</dc:creator>
      <pubDate>Thu, 26 Jan 2023 20:08:08 +0000</pubDate>
      <link>https://dev.to/keffdu/using-react-h5-audio-player-ogj</link>
      <guid>https://dev.to/keffdu/using-react-h5-audio-player-ogj</guid>
      <description>&lt;p&gt;As I get further into my journey as a software engineer, I have spent more time trying to utilize and understand how to use many different &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;npm&lt;/a&gt; packages. They can be super useful and really streamline the development process, saving you time from building something by scratch and troubleshooting.&lt;/p&gt;

&lt;p&gt;I recently came across the &lt;a href="https://www.npmjs.com/package/react-h5-audio-player" rel="noopener noreferrer"&gt;React H5 Audio Player&lt;/a&gt; package when planning a project for users to upload and playback music. This package takes care of all the dirty work necessary in building your own media player and also allows for some customization and options. I'm going to discuss how to install, and incorporate this package in your next project&lt;/p&gt;

&lt;p&gt;To start, you need to either list this package inside the package.json file OR in a terminal within your project directory - you can run the command to install it. I'll go over each of those steps:&lt;/p&gt;

&lt;h2&gt;
  
  
  Inside package.json file:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fhiktqb7sbf9mzwapb8d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhiktqb7sbf9mzwapb8d6.png" alt="package.json" width="800" height="769"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;each of these items listed under "dependencies" is a package that can be utilized when building your code. You can list your Audio Player package in this section by writing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"react-h5-audio-player": "3.8.6"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then once you go begin to build your project, you will run in the terminal&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;which will go through that package.json file and install all dependencies listed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install from the terminal
&lt;/h2&gt;

&lt;p&gt;If you would rather just install this package directly from the terminal instead, heres how you would do that.&lt;/p&gt;

&lt;p&gt;go to the project directory within your terminal, once inside it write the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i react-h5-audio-player
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this will install the "react-h5-audio-player", and list in as a dependency in your package.json file for you. Once that is done you will have access to that package within your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the audio player
&lt;/h2&gt;

&lt;p&gt;theres many different ways you can configure this audio player based on your needs, its worth reading the &lt;a href="https://www.npmjs.com/package/react-h5-audio-player" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; or look through this Storybook demo and interact with it or read more information on configurations by clicking the "doc" tab at the top of the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fp2q6cj96tl7lwdtdy8wa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fp2q6cj96tl7lwdtdy8wa.png" alt="documentation" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are tens of thousands of packages from &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;npm&lt;/a&gt; that can streamline your development process and make your life as a programmer easier, because why reinvent the wheel, right? I encourage you to look through all the possible packages out there that you may already exist before starting a project and trying to build something from scratch. Happy Coding!&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Controlled Forms - Why do we need them?</title>
      <dc:creator>Kevin Dutzy</dc:creator>
      <pubDate>Fri, 09 Dec 2022 17:09:36 +0000</pubDate>
      <link>https://dev.to/keffdu/controlled-forms-why-do-we-need-them-5g23</link>
      <guid>https://dev.to/keffdu/controlled-forms-why-do-we-need-them-5g23</guid>
      <description>&lt;p&gt;With learning react over the past three weeks, there was a lot of discussion about controlled forms vs. uncontrolled forms, and a big emphasis on why we should use controlled components instead. Let's first break down exactly what the difference is between the two..&lt;/p&gt;

&lt;h2&gt;
  
  
  Forms -
&lt;/h2&gt;

&lt;p&gt;Traditionally forms store &amp;amp; maintain their own state, and it will get updated when you query the DOM and pull the current value. React takes a different approach by taking the current value through props, storing the values to state inside the component, and monitoring any changes through the &lt;code&gt;onChange&lt;/code&gt; callback. The main difference is that a &lt;em&gt;controlled&lt;/em&gt; component is all handled completely by react. Take a look and this screenshot of what a controlled form looks like, the key indicators are having the input value set to the state, and having an &lt;code&gt;onChange&lt;/code&gt; attribute on the input as well. &lt;/p&gt;

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

&lt;p&gt;notice we attached the &lt;code&gt;onChange&lt;/code&gt; callback to the input, and every time there is a change on the input it is triggering a helper function, which will be taking in that value and setting it to state, which is either declared inside the component or passed down from a parent component. We then take the &lt;code&gt;value=&lt;/code&gt; attribute and assign our state to it. So now every time a change happens, it updates state, which is then assigned back to the value of the form in almost this looping type of way. This is what truly makes a controlled form, everything is handled within react and not pulled from the DOM. &lt;/p&gt;

&lt;p&gt;There is very little reason to ever choose an uncontrolled form compared to a controlled one, in most cases you will always want it to be controlled with React. It allows you to have more flexibility with managing state inside the components, you can also have several inputs for one piece of data, and also allows you to have dynamic inputs as well. &lt;/p&gt;

&lt;p&gt;If you are interested in learning more about &lt;a href="https://reactjs.org/docs/forms.html"&gt;controlled forms&lt;/a&gt; take a look at the documentation from react.js. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>InnerText vs. InnerHTML vs. TextContent</title>
      <dc:creator>Kevin Dutzy</dc:creator>
      <pubDate>Fri, 18 Nov 2022 18:12:54 +0000</pubDate>
      <link>https://dev.to/keffdu/innertext-vs-innerhtml-vs-textcontent-1d5c</link>
      <guid>https://dev.to/keffdu/innertext-vs-innerhtml-vs-textcontent-1d5c</guid>
      <description>&lt;h1&gt;
  
  
  Which do I use? When? Why?
&lt;/h1&gt;

&lt;p&gt;You aren't alone if you find it daunting on which of these to choose and the nuances between them. This post will help break down, and give you a better understanding of them and when it's appropriate for each to use.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Breakdown
&lt;/h2&gt;

&lt;p&gt;These all share basically the same core function - which is to pull the contents inside elements. It begins to vary when it comes to what content is grabbed, and how it is also rendered on the page. &lt;/p&gt;

&lt;p&gt;We will start with a few comparisons between InnerText and TextContent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Mainly, TextContent allows you to grab &lt;strong&gt;ALL&lt;/strong&gt; elements, where as InnerText is only going to use what's considered human readable elements. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;InnerText can read CSS styles and will display them, TextContent will only display the content without any styling.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a photo example from &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText"&gt;MDN&lt;/a&gt; showing how innertext and textcontent display differently &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cA9oPeXd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm6takmzb6nqdlrm8odt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cA9oPeXd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm6takmzb6nqdlrm8odt.png" alt="Image description" width="590" height="902"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#differences_from_innertext"&gt;MDN&lt;/a&gt; has great references for getting a deeper understanding of how these all relate to each other and how they differ as well. I highly recommend using that site as much as you can in general, although there is a lot of information to sift through - it is very reliable and thoroughly explained.&lt;/p&gt;

&lt;h2&gt;
  
  
  InnerHTML
&lt;/h2&gt;

&lt;p&gt;This one gets a little more confusing, and I feel like depending on the person you ask, you will get different opinions as to how they feel about using it. InnerHTML will actually take the text and whatever html tags are attached with it and either replace them with your assigned content, or you can grab existing content and append new contents to the existing one of an element. Take a look at &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML"&gt;MDN's&lt;/a&gt; documentation explaining the usage and &lt;strong&gt;DANGER'S&lt;/strong&gt; of using InnerHTML over the other methods. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>html</category>
    </item>
  </channel>
</rss>
