<?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: Adrian0506</title>
    <description>The latest articles on DEV Community by Adrian0506 (@adrian0506).</description>
    <link>https://dev.to/adrian0506</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%2F513221%2F0f84e82c-bd40-4665-94f3-81d0dacfdb5f.png</url>
      <title>DEV Community: Adrian0506</title>
      <link>https://dev.to/adrian0506</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adrian0506"/>
    <language>en</language>
    <item>
      <title>React Hooks</title>
      <dc:creator>Adrian0506</dc:creator>
      <pubDate>Wed, 13 Jan 2021 04:12:39 +0000</pubDate>
      <link>https://dev.to/adrian0506/react-hooks-170j</link>
      <guid>https://dev.to/adrian0506/react-hooks-170j</guid>
      <description>&lt;p&gt;React hooks are a pretty amazing tool in Javascript. You can easily change a components state without making it a class. It is fairly simple and easy to use. It saves a lot of time and you can use them multiple times in a single component. &lt;br&gt;
I will show you a example of how react hooks will look.&lt;/p&gt;

&lt;p&gt;import React, {useState} from 'react';&lt;/p&gt;

&lt;p&gt;function App () {&lt;br&gt;
let [currentCount, incrementCount] = useState(0);&lt;/p&gt;

&lt;p&gt;return &amp;lt;&amp;gt;&lt;/p&gt;
&lt;h1&gt;Click Me&lt;/h1&gt;

&lt;h1&gt;{currentCount}&lt;/h1&gt;

&lt;p&gt;&amp;lt;/&amp;gt;&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;This small function basically creates a variable with a value of 0. When you click on click me it increments the count. Which will change that variables state. This will cause the page to re render to show the correct count. I like using hooks because I believe it makes code look cleaner, you also have to write less lines of code to change the state. I feel like this is fairly popular among developers. &lt;/p&gt;

&lt;p&gt;Also some examples can be maybe you want to render something based if the state is true or false, with useState it is basically works as a toggle. When you click something you can toggle it to be true and then when you click it again you can toggle it to be off. If you want more complex states you may have to use a class component in order to pull it off.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Javascript Async/await</title>
      <dc:creator>Adrian0506</dc:creator>
      <pubDate>Wed, 16 Dec 2020 03:07:38 +0000</pubDate>
      <link>https://dev.to/adrian0506/javascript-async-await-43km</link>
      <guid>https://dev.to/adrian0506/javascript-async-await-43km</guid>
      <description>&lt;p&gt;I have recently learned about JavaScripts Asnyc functions! At first they were really confusing. I have been using them primarily for node.js. The way Async functions work is that say you are reading a file in node js. Let me make a short example.&lt;/p&gt;

&lt;p&gt;function readFile () {&lt;br&gt;
let data = readFile('./src/index.txt');&lt;br&gt;
console.log(data)&lt;br&gt;
} &lt;br&gt;
   console logs undefined;&lt;/p&gt;

&lt;p&gt;The reason this logs undefined is because we are not waiting for the data to come back. We instantly go to the next like to log the data. But since it hasnt come but we do not know what is in data so as a result it logs undefined. Here is a different example of a working solution to this problem.&lt;/p&gt;

&lt;p&gt;function readFile() {&lt;br&gt;
 readFile('./src/index.txt', function (err, data) {&lt;br&gt;
   if (err) {&lt;br&gt;
   return err&lt;br&gt;&lt;br&gt;
  } else {&lt;br&gt;
  console.log(data)&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Instead we give it a call back! The call back runs when it finished reading the file and is ready to return a result. We also have a err argument that only runs when a err is found. we could also do this a different way by stopping the code until it comes back with a response, but the problem with this is that it will not run another line of code until it returns a response! It could slow down your application a lot! Here is a example of that.&lt;/p&gt;

&lt;p&gt;function async readFile() {&lt;br&gt;
let data = await readFile('./src/index.txt')&lt;br&gt;
console.log(data)&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;This time it will fine the data but the await keyword will stop the code until it receives something in return!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Hack Reactor Week 3 (react)</title>
      <dc:creator>Adrian0506</dc:creator>
      <pubDate>Wed, 09 Dec 2020 03:23:28 +0000</pubDate>
      <link>https://dev.to/adrian0506/hack-reactor-week-3-react-3ihn</link>
      <guid>https://dev.to/adrian0506/hack-reactor-week-3-react-3ihn</guid>
      <description>&lt;p&gt;Hey everyone! I have just gotten to my 3rd week of hack reactor. It has been very fun and I have been enjoying it a lot! But I want to talk about react states! React states is such a powerful tool! It constantly re renders a page if the state of something has been changed. Let me model a demonstration!&lt;/p&gt;

&lt;p&gt;class App extends React.Component {&lt;br&gt;
  constructor(props) {&lt;br&gt;
   super(props)&lt;br&gt;
   this.state = {&lt;br&gt;
    counter: 0;&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;incrementCounter() {&lt;br&gt;
  let currentVal = 0;&lt;br&gt;
  currentVal++; &lt;br&gt;
setState({&lt;br&gt;
  counter: currentVal&lt;br&gt;
 })&lt;br&gt;
}&lt;br&gt;
  Render() {&lt;/p&gt;

&lt;p&gt;return &lt;/p&gt;
&lt;h1&gt;Click me! {this.state.counter}&lt;/h1&gt;
&lt;br&gt;
 }&lt;br&gt;
}

&lt;p&gt;What is awesome about this is that it will re render the entire page when you click on the click me element! And can be used in many different ways. Examples can be like whenever a user sends a tweet. The state of the current tweets are tracked. When we add a new tweet it changes the state and re render the page to display that new tweet! You can find a way to do this in vanilla js. But react does that for us and helps us save so much time!&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Hack Reactor DAY 2!</title>
      <dc:creator>Adrian0506</dc:creator>
      <pubDate>Tue, 17 Nov 2020 21:20:18 +0000</pubDate>
      <link>https://dev.to/adrian0506/hack-reactor-day-2-4dj9</link>
      <guid>https://dev.to/adrian0506/hack-reactor-day-2-4dj9</guid>
      <description>&lt;p&gt;Going through hack reactor has been fun so far. Been learning a lot and collaborating with others!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>career</category>
    </item>
  </channel>
</rss>
