<?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: Austin Turner</title>
    <description>The latest articles on DEV Community by Austin Turner (@aturn).</description>
    <link>https://dev.to/aturn</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F621977%2Fde79c4db-b937-411f-a137-0457afe40a30.png</url>
      <title>DEV Community: Austin Turner</title>
      <link>https://dev.to/aturn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aturn"/>
    <language>en</language>
    <item>
      <title>State... The Thing Everyone Hates</title>
      <dc:creator>Austin Turner</dc:creator>
      <pubDate>Mon, 16 Aug 2021 02:00:53 +0000</pubDate>
      <link>https://dev.to/aturn/state-the-thing-everyone-hates-4epg</link>
      <guid>https://dev.to/aturn/state-the-thing-everyone-hates-4epg</guid>
      <description>&lt;h1&gt;
  
  
  What is state?
&lt;/h1&gt;

&lt;p&gt;State at its core is a React Hook. A React Hook is a special function that lets you have access to or "hook into" certain React features. The &lt;code&gt;useState&lt;/code&gt; React Hook lets you add a state to a functional component. This allows you to set certain data to a variable that can be used in the component that you added state too, and its children as well passed down via props.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to use State
&lt;/h1&gt;

&lt;p&gt;The first thing you need to do to get state up and running is to import the &lt;code&gt;useState&lt;/code&gt; React Hook. That would look like so...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react'
// or
import { useState } from 'react'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you need to declare your state variable and setter function in an array format with a &lt;code&gt;const&lt;/code&gt; and set that equal to the &lt;code&gt;useState&lt;/code&gt; Hook. In my example I will be using state to determine if the app is currently in dark mode or light mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
const [darkMode, setDarkMode] = useState(false)

return...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the parentheses of the &lt;code&gt;useState&lt;/code&gt; Hook is what the default value of the state you just created. In this example I only need to check if dark mode is on (true) or off (false). Currently it is off due to the default value I gave to the state. Next thing to do is to wright a new function that will change the current value of the state. (This function will be called when the user clicks a button to turn dark mode on.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
const [darkMode, setDarkMode] = useState(false)

function handleDarkMode() {
  setDarkMode(!darkMode)
}

return(
 &amp;lt;div&amp;gt;
   &amp;lt;button onClick={handleDarkMode}&amp;gt; Dark Mode &amp;lt;/button&amp;gt;
 &amp;lt;/div&amp;gt;
)
}

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

&lt;/div&gt;



&lt;p&gt;The Function &lt;code&gt;handleDarkMode&lt;/code&gt; calls our setter function in state &lt;code&gt;setDarkMode&lt;/code&gt;. In the parentheses of the setter function is what you want the new value of state to be. In the example above, I set the new value of state to be &lt;code&gt;!darkMode&lt;/code&gt; or "not" &lt;code&gt;darkMode&lt;/code&gt; which will change the value to true instead of false. With this basic set up I can tell the app to change the overall style of the app if the value of &lt;code&gt;darkMode&lt;/code&gt; is true or false. &lt;/p&gt;

&lt;h1&gt;
  
  
  Wrapping it all up
&lt;/h1&gt;

&lt;p&gt;This is just the beginning and something very basic that &lt;code&gt;useState&lt;/code&gt; can be used for. Learning state was not an easy or quick thing to do. I am still working on fully understanding everything that the &lt;code&gt;useState&lt;/code&gt; React Hook can be used for! Some things that helped me when learning this was that...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The variable that you declare for your state is just like declaring any other normal const variable. It is a variable that has data stored in it. &lt;/li&gt;
&lt;li&gt;The setter function is what you use when you want to change the data that is being stored in your variable. &lt;/li&gt;
&lt;li&gt;Lastly, and probably the most tricky, is to always think about what component you want to declare your state in. If the component you are currently in has no use for the data you need to store in state, you might need to go up or down your app's hierarchy to see what component is best suited to hold that state. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep those simple things in mind and you will be mastering state in no time!    &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Fresh eyes on stylesheets!</title>
      <dc:creator>Austin Turner</dc:creator>
      <pubDate>Sun, 20 Jun 2021 19:49:38 +0000</pubDate>
      <link>https://dev.to/aturn/fresh-eyes-on-stylesheets-28kh</link>
      <guid>https://dev.to/aturn/fresh-eyes-on-stylesheets-28kh</guid>
      <description>&lt;h3&gt;
  
  
  Rundown
&lt;/h3&gt;

&lt;p&gt;Over the last two weeks I've been working on a project for my Software Engineering class I am taking through FlatIron School. The task was to build a single page web application from scratch using everything we had learned pior, plus researching new things we didn't have much understanding on through google. One of the biggest things I was most curious about was styling a page with CSS. Then my instructor told our class about stylesheets and I was instantly intrigued!&lt;/p&gt;

&lt;h3&gt;
  
  
  CSS Made Simple!
&lt;/h3&gt;

&lt;p&gt;My instructor gave us three websites to look into if we were curious about diving into styling our web app but didn't want to take the time to learn everything there is about basic CSS. The three that she mentioned where &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Semantic UI&lt;/li&gt;
&lt;li&gt;Bootstrap&lt;/li&gt;
&lt;li&gt;Materialize&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After looking at each of their sites I decided to go with Materialize because I liked more of their modern designs that they offered. &lt;/p&gt;

&lt;h3&gt;
  
  
  How I Used Materialize!
&lt;/h3&gt;

&lt;p&gt;The biggest thing that I was curious about was how to get certain items in your html to be displayed on certain parts of the page! Materialize (and other stylesheets) use certain class names to style the page based on the tag given. For displaying content in a grid, Materialize uses a &lt;code&gt;container&lt;/code&gt; class on a &lt;code&gt;section&lt;/code&gt; tag and a &lt;code&gt;row&lt;/code&gt; class on a &lt;code&gt;div&lt;/code&gt; tag. Then, to separate the container, you want you use a &lt;code&gt;col&lt;/code&gt; class on a child &lt;code&gt;div&lt;/code&gt; tag and state how many spaces you want the row to be. There are 3 different size options you can use depending on how big the screen size is.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;s&lt;/code&gt; for small screens&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;m&lt;/code&gt; for medium screens&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;l&lt;/code&gt; for large screens&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All 3 of the sizes can be used in a single tag so your web page can be adaptable depending on the users screen size. After you choose which or how many you want to include, you put a number after the &lt;code&gt;s&lt;/code&gt;, &lt;code&gt;m&lt;/code&gt;, or &lt;code&gt;l&lt;/code&gt; to state how much space in that row of the container you want it to take up. There are a total of 12 spaces that take up an entire screen when using this method, so in the example below, my section for the &lt;code&gt;tabs&lt;/code&gt; take up the entire top part of the screen. Then each of the tabs splits those 12 spaces equally by each of them being 6 spaces long.&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;section class="container section"&amp;gt;
            &amp;lt;div class="row"&amp;gt;
                &amp;lt;div class="col l12"&amp;gt;
                    &amp;lt;ul class="tabs"&amp;gt;
                        &amp;lt;li class="tab col s6"&amp;gt;
                            &amp;lt;a href="#database" class="green-text text-darken-3"&amp;gt;Database&amp;lt;/a&amp;gt;
                        &amp;lt;/li&amp;gt;
                        &amp;lt;li class="tab col s6"&amp;gt;
                            &amp;lt;a href="#generator" class="green-text text-darken-3"&amp;gt;Generator&amp;lt;/a&amp;gt;
                        &amp;lt;/li&amp;gt;
                    &amp;lt;/ul&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Materialize and other stylesheets like Bootstrap offer far more than just displaying html in certain places on the screen. The tabs in the example above are also something the Materialize provides in there stylesheet. But I think that taking this approach was a life saver for me to be able to make my project look a little more cleaner without having to do hours on hours of researching CSS. It's almost as simple as plug and play and very intuitive when you get the hang of it. I would highly recommend any new programmers who don't have a lot of time to spare but are  wanting to add a little flair to their programs to look into Materialize or other stylesheets.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>css</category>
    </item>
  </channel>
</rss>
