<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Brian Rhodes on Medium]]></title>
        <description><![CDATA[Stories by Brian Rhodes on Medium]]></description>
        <link>https://medium.com/@brianr4548?source=rss-a686ed2435a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2hqX-cg2K5EckkVD.jpg</url>
            <title>Stories by Brian Rhodes on Medium</title>
            <link>https://medium.com/@brianr4548?source=rss-a686ed2435a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:47:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brianr4548/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Redux-Form: Basic overview and thoughts.]]></title>
            <link>https://brianr4548.medium.com/redux-form-basic-overview-and-thoughts-4cd5efe8bc34?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cd5efe8bc34</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react-redux]]></category>
            <category><![CDATA[redux-form]]></category>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Sun, 26 Sep 2021 22:38:17 GMT</pubDate>
            <atom:updated>2021-09-26T22:38:17.592Z</atom:updated>
            <content:encoded><![CDATA[<p>Everyone knows redux is a very tedious state management system to work within general. However, one of the upsides of using it is how easy it is to utilize redux-form. Redux-form is a state management system for forms that utilize React and Redux. Unlike react-redux, it does not require much initial setup and it even requires less setup in terms of forms compared to non-redux applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3jVX0T9-4VQLVnupDZxpw.png" /></figure><p>The first thing I noticed about redux-form is that a lot of the typical redux boiler-plate is not needed. React-form comes with the <em>action creators</em> and <em>reducer</em> already set up under the hood. The only step you need to take is implementing it inside your <em>combineReducers()</em> method. What a relief!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*ykqBIa4VeTHewjyasJ_bNg.png" /></figure><p>The second thing I noticed was how similar the setup up is compared to react-redux. In react-redux, you utilize the <em>connector()</em> method at the bottom of your application’s<em> export default</em>. Redux-form has a similar method in order to give you access to the redux-form methods. Every function you create afterward will contain props with all the redux-form methods. The first key in the reduxForm connector object should always be form and the value is what you want your form’s name to be saved as in your state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*BVnvGjC0lXdqRJF9s6C_Xw.png" /></figure><p>The third the I noticed was the obscurity of the <em>Field Component</em>. The Field Component more so serves as a mediator. You essentially build it the same as a regular input except the Field Component contains a property called <em>component</em>. The component property is where you really build out your input tag by passing it into the Field. It is also important to note that Field has no idea what a label is. What happens under the hood is that it passes those properties into the component property and it attaches itself accordingly. The name property is what you want your state key to be named.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*IS1hVkt5ew3Rnl_V6HqUDw.png" /></figure><p>It is a slightly tedious two-step process but it is essential in order for redux-form to work. Building out separate functions to return the JSX allows you to easily manipulate the <em>formProps </em>which quite frankly stores everything you need for your forms. All the information you will ever need is stored in the props given to you from redux-form.</p><p>For example <em>onChange</em> and<em> input values</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*cY2O6-BEbP7paJETM3pnsw.png" /></figure><p>Or even things for form submittal like <em>handleSubmit()</em> which require a little less code to for intial setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*9zd-6Tu5v8oF_jyHBP1jdw.png" /></figure><p>The easiest way to find out about the methods is by console logging the props and finding testing them out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*Vk4EwgmCuuJmhyJ2jMIKzQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cd5efe8bc34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Minor things to make redux a bit easier to work with.]]></title>
            <link>https://brianr4548.medium.com/minor-things-to-make-redux-a-bit-easier-to-work-with-aca41ebfb8c5?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/aca41ebfb8c5</guid>
            <category><![CDATA[react-redux]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-redux-boilerplate]]></category>
            <category><![CDATA[reactreduxcoding]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Mon, 20 Sep 2021 01:00:39 GMT</pubDate>
            <atom:updated>2021-09-20T01:00:39.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uov-TfA20xfGqeIZyLWfnA.png" /></figure><p>Over the period I’ve spent learning Redux, I noticed that there are mixed reviews in terms of people’s overall opinion of it. Most complaints I’ve heard so far are pertaining to the amount of boilerplate required to do simple tasks, and it is true. Redux does require tons of initial setup just to get simple things to work. In small applications, redux isn’t needed. But in larger applications, redux is a must-have to manage <em>state</em>. Because redux requires so much boilerplate code, it can be easy to mess things up along the way and come across very vague errors. This article serves to help make your redux management more organized and clean. It may not reduce the boilerplate needed but it will keep you from having a headache:</p><ul><li><strong>Use variables for the type property</strong>: a common mishap is misspelling the type property whether it be in your action creator or reducer. The error that forms isn’t the most intuitive to go off of either. To make it easier on yourself you can create a separate JavaScript file inside the actions folder called <em>types.js. </em>In this file store all your types in one place and export them to the action creators and reducers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*rUHy8SSOWVlJjt8Ze9sguw.png" /></figure><ul><li><strong>Create reducers in separate files: </strong>You could keep every reducer in the index.js and use the <em>combineReducer()</em> method from there. But reducers can become pretty sizeable and are not required to be in the same file. A good way to organize reducers is the use the <em>index.js </em>file only for the <em>combineReducer()</em> method. inside the <em>reducers folder</em> create separate files for each reducer and export them to the <em>index.js</em> file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/162/1*2mHjuJwtpunZxaKc1wJVHw.png" /></figure><ul><li><strong>Setting an initial state with an outside variable inside your reducer: </strong>This is very nuanced and depends on what you are working on and what values you are dealing with. Sometimes it can be beneficial to declare a variable with your initial state object inside of reducers. This is great especially if you are expecting to receive an object. This is a pretty simple trick with wide uses but it can help you organize the initial state and keep it clean if you are initializing multiple objects. It can also reduce the amount of information you have to sift through from your <em>payload</em>. For example, instead of utilizing the payload for boolean values, initialize it so you can save more time.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*PdnfxDiRXE2_QI6zyFKeew.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aca41ebfb8c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React-Redux Easy Explanation (2/2)]]></title>
            <link>https://brianr4548.medium.com/react-redux-easy-explanation-2-2-4947bf2fab6d?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4947bf2fab6d</guid>
            <category><![CDATA[react-redux]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[reducer]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 00:58:32 GMT</pubDate>
            <atom:updated>2021-09-12T00:58:32.107Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous article I wrote, I went over the Redux Cycle. This article is going to focus on React-Redux. Firstly, why react-redux? As you continue to work on an application, Managing the state can become very convoluted. React-Redux is a <em>State Management System</em> to make managing State easier.</p><p><strong>The React-Redux boilerplate:</strong></p><p>If you want to create an <em>Action</em> or <em>Reducer</em> it is best practice to create folders names <strong>Actions</strong> and <strong>Reducers</strong> on the top level of the <strong>src folder</strong>. Inside both folders create an <em>index.js</em> file. Now you should have a total of 3 <em>index.js</em> files.</p><p>In the initial <em>index.js</em> file that you attach your <em>App.js</em> file to, import {Provider} from &#39;react-redux&#39; and import {createStore} from &#39;redux&#39; . Wrap your App component in the providers like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*i-aqH0dKoS8ih6kpiMBXdA.png" /></figure><p>Now a lot of your boilerplate is done. From here you can create your actions. inside the<em> index.js</em> file inside of the <strong>actions folder, </strong>the process is exactly as shown before except with an <strong>export statement</strong> beforehand. It is important to know you should not but using export default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*D0-kp6VtUWNf04DzmxeMdQ.png" /></figure><p>In your reducers file, import {combineReducers} from &#39;redux&#39; and create your reducers. The difference here is <strong>exporting the reducers by default</strong>.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*I_1RdY-D1PHLklZnpkj2Lg.png" /></figure><p><strong><em>The information before was basically recapping and integrating reducers into React this section will cover some glaring differences:</em></strong></p><p>Whichever file you want to call <em>State,</em> you must first import {connect} from &#39;react-redux&#39; and connect it to your <strong>export default</strong> like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*LDZnd9umfriylt1AePM5Og.png" /></figure><p><strong>mapStateToProps</strong> is a function that also goes inside your <strong>connector</strong> in order to use your <em>State</em> inside a component. Its job is just as its title says so in your component, you will need to use <em>Props</em> to access the <em>State</em> via the key you pick. it is also important to note that the <strong>connect function automatically dispatches.</strong></p><p>Lastly, connect the <strong>createStore function</strong> to your provider to allow the <strong>connector</strong> to communicate with the <strong>Provider</strong> so it can send information to your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*vsteM4Dg7Esag3pf8WK0LA.png" /></figure><p>Now you are free to build applications just as you used to except with React-Redux.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4947bf2fab6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Redux Cycle Simplified. (1/2)]]></title>
            <link>https://brianr4548.medium.com/the-redux-cycle-simplified-a86a50be086?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a86a50be086</guid>
            <category><![CDATA[redux-form]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react-redux]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 05:13:48 GMT</pubDate>
            <atom:updated>2021-09-12T00:58:51.101Z</atom:updated>
            <content:encoded><![CDATA[<p>A major part of learning React is also learning Redux. Redux makes managing <em>state</em> easier in complex applications by centralizing the information in one place. Before learning React with Redux it is important to know each part of the “Redux Cycle”.</p><ul><li><strong>Actions Creators and Actions</strong>: Every Action Creator returns an action. <em>Action Creators</em> are functions that return the <em>action</em> object. Actions are objects where you store your information regarding data and state. The action object itself should have two keys, a <em>type</em>, and a <em>payload</em>. The type should be a custom named string that you can reference later. Best practices are to use all capital letters and underscores in the place of spaces. It is also best practice to use concise names. If you are creating a payment you would probably name the Type: “CREATE_PAYMENT”. The payload, on the other hand, returns another object that contains the data you want to manipulate.</li></ul><pre>const createPayment = (name, paymentAmount) =&gt; {<br>  return {<br>    type: &quot;CREATE_PAYMENT&quot;,<br>    payload: {<br>      name: name,<br>      amount: paymentAmount<br>    }<br>  };<br>};</pre><ul><li><strong>Reducers and Dispatching</strong>: <em>Reducers</em> are functions designed to manipulate certain action’s payloads which will end up changing the state. Each reducer takes a first initial argument of your choosing. It is best practice to default it to a certain value as well. below, oldListOfPayments is expecting an array and funds is expecting a number. The second argument is the action itself. This is how you manipulate the payload. It is also important to note, that at the end of each if statement below, the entire data set is always returned whether it changes or not. this is to consolidate everything in one place.</li></ul><pre>const paymentHistory = (oldListOfPayments = [], action) =&gt; {<br>  if (action.type === &quot;CREATE_PAYMENT&quot;) {<br>    return [...oldListOfPayments, action.payload];<br>  }<br>  return oldListOfPayments;<br>};</pre><pre>const bankAccounts = (funds = 100, action) =&gt; {<br>  if (action.type === &quot;CREATE_PAYMENT&quot;) {<br>    return funds - action.payload.paymentAmount;<br>  } else if (action.type === &quot;CREATE ACCOUNT&quot;) {<br>    return funds + action.payload.paymentAmount;<br>  }<br>  return funds;<br>};</pre><ul><li><strong>Dispatch</strong>: <em>Dispatching</em> is the MOST IMPORTANT PART. EVERY ACTION is sent(dispatched) to EVERY REDUCER. However, every reducer or section of a reducer doesn’t have to use every action. In the code above, both reducers are looking for the “CREATE_PAYMENT” type through a <em>boolean</em>. The action will run depending on if the boolean is true or false. After that, regardless of whether the payload changes, the data will be returned. The below code is what makes this possible.</li></ul><pre>const { createStore, combineReducers } = Redux;</pre><pre>const all = combineReducers({<br>  paymentHistory: paymentHistory,<br>  bankAccounts: bankAccounts<br>});</pre><pre>const store = createStore(all);</pre><pre>const action = createPayment(&#39;brian&#39;, 100)</pre><pre>store.dispatch(action)</pre><p>The idea is to “combine reducers” and create a “store” that way when you “dispatch” an action, it goes through booleans for every reducer, applying itself to the correct ones and changing the state.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a86a50be086" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keynotes for useEffect (React)]]></title>
            <link>https://javascript.plainenglish.io/useeffect-key-notes-react-8fa1b3d92ce4?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fa1b3d92ce4</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Sun, 22 Aug 2021 23:27:31 GMT</pubDate>
            <atom:updated>2021-08-28T19:12:49.480Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iq_xUySrcOf8k4ZwSeMzDw.jpeg" /></figure><p>If you are utilizing React’s hook system, then you are using the useEffect life cycle method in place of the usual componentDidMount method for class-based components. In this method, there’s almost always code related to the HTTP requests you make. This article’s purpose is to show and explain a couple of neat keynotes about useEffect to spice up your application.</p><h4><strong>useEffect’s second argument:</strong></h4><p>Like every example I have displayed in previous articles, it will be in the form of a simple search component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*KnRyQO8SLP1SK-9HyJ9xMQ.png" /></figure><p>Notice at the very end there is a second argument of[term] . Here are the rules of the second argument of useEffect:</p><ul><li>The second argument can only be one of three things:<strong> blank</strong>, an <strong>empty array</strong>, or an <strong>array with elements inside</strong>.</li><li>If the second argument is <strong>blank</strong> then useEffect will only run on the initial render of the component.</li><li>If the second argument is an <strong>empty array</strong> then useEffect will run at the initial render and every single re-render</li><li>If the second argument is an <strong>array filled with elements</strong>, then useEffect will run at the initial render and every re-render <strong>IF</strong> the data inside the array changes.</li></ul><p>How does this relate to a search function?</p><p>Well if we take a look at our second argument, it is an array with an element inside called term . Somewhere else in this imaginary application there is an onChange event keeping track of said term (every character change).</p><p>What the second argument allows us to do is make requests without requiring an onSubmit event. This is a neat way to add some flair to your applications. Each key press will automatically do a search for you.</p><p><strong>2. useEffect’s return statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*1DUnkYb5ywaA9Q8uaW_hXA.png" /></figure><p>The return for useEffect is very unique. It only has one rule:</p><ul><li>You can only return an arrow function.</li></ul><p>When the component is initially rendered, the return isn’t invoked but the reference to the function is saved. When the component re-renders that is when the return is invoked before anything else even runs. Use console.log to try it out yourself.</p><p>How can this be used?</p><p>For the search component in the examples, a search is performed every keypress which will make tons of requests that you don’t necessarily want to make. To combat this, you can do a simple setTimeOut to delay when the search happens after pressing a key. But, the problem with that is that the timer will not reset every keypress and will instead start at the first keypress and end at the exact time from that press. So if you are typing “Electronic Cars” it might do a search in middle, only searching for “Electro” due to the timer still running.</p><p>How do we fix this?</p><p>Well, you could increase the duration of the timer or type faster. But it would be more practical to clear it after every re-render. That is what the return statement in the example above is for. After every keypress, the timer will reset making it so you can type long words/sentences like “How do I use useEffect?” in the input field without the timer invoking the search in the middle. Give it a try!</p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fa1b3d92ce4" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/useeffect-key-notes-react-8fa1b3d92ce4">Keynotes for useEffect (React)</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React: What is ‘this’ and why am I getting this Error?]]></title>
            <link>https://javascript.plainenglish.io/react-what-is-this-and-why-am-i-getting-this-error-89e6a5a2f24?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/89e6a5a2f24</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Sun, 15 Aug 2021 02:27:51 GMT</pubDate>
            <atom:updated>2021-08-15T16:10:00.551Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iq_xUySrcOf8k4ZwSeMzDw.jpeg" /></figure><p>If you are unfamiliar with <em>Class-based</em> components you are bound to come across this error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*WoiWF3n6jF__lMZbs8C5ew.png" /><figcaption>(this error can also say ‘state’ of undefined)</figcaption></figure><p>You’ll look back at your code for minutes and see nothing wrong. You’ll keep asking yourself why is ‘props’ (or ‘state’) undefined!? I am clearly passing information to it!!!</p><p>This stems from how the keyword ‘this’ operates. To start, ‘this’ is a reference to the Class itself. When you are writing this.functionName it is essentially the same thing as className.functionName. Or if you are using state it would be this.state.stateKey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*5wXje68xh5JHVMX3wo7m5w.png" /></figure><p>The issue lies in where you invoke the keyword ‘this’. The <strong>image above</strong> is a Class function for submitting a form. This is the exact function that led to the error at the top. The easy explanation for this error is that when this.props is called within the function, it is calling ‘this’ only inside the function and not referencing the class, essentially stripping the function from the class.</p><p>There are two solutions to this problem:</p><ol><li>If you want, you can use a constructor and add the code below. This will bind the function to the Class that way ‘props’ will be recognized from the Class and not the function. But I only suggest using this method if you are already using constructor + super.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*j3UCfuffb5-scyXPQC7fZw.png" /></figure><p>2. The other way is simple. Just convert your functions into arrow functions. Arrow functions are the new ES6 way of writing functions and they automatically bind to JavaScript classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*gjChMwLzm1gceRavHGAzvw.png" /></figure><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89e6a5a2f24" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/react-what-is-this-and-why-am-i-getting-this-error-89e6a5a2f24">React: What is ‘this’ and why am I getting this Error?</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Hooks: Easier Than You Think]]></title>
            <link>https://javascript.plainenglish.io/react-hooks-easier-than-you-think-b48d9d2b6080?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b48d9d2b6080</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Mon, 09 Aug 2021 20:47:24 GMT</pubDate>
            <atom:updated>2021-08-16T06:35:47.789Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M3CJsHjPEMWqUJak" /><figcaption>Photo by <a href="https://unsplash.com/@flowforfrank?utm_source=medium&amp;utm_medium=referral">Ferenc Almasi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Sometimes learning new things can be overwhelming and tedious. However, that is not the case for <em>React Hooks</em>. If you are someone who has never taken the time to learn <em>Hooks</em> and you primarily use <em>Class-base</em>d components, it might be time to give it a try.</p><p>When I first learned <em>React</em>, I only used <em>Class-based</em> components because it is what I was taught and was most familiar with. However, while it is good to know how to utilize <em>Class-based</em> components, they are “outdated”. The industry is and will continue down the path of using <em>Function-based</em> components.</p><p><em>Hooks</em> were created as a way to use <em>Class</em> lifecycle methods and <em>State</em> inside of functions. This essentially eliminates the need for <em>Class-based</em> components in general.</p><p><strong>The easiest way to demonstrate this is by looking at <em>State</em> in a <em>Class-based</em> component:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*FZ8br09wJd3QRgls1G2aVw.png" /></figure><p>The four main takeaways to look at are:</p><ul><li><em>State </em>is initialized by state: {} .</li><li>The This keywords for targeting functions and variables in <em>Classes</em>.</li><li>The necessity of arrow functions to avoid errors with thethis keyword in <em>Class-based</em> components.</li><li>setState() for any changes in <em>State</em>.</li></ul><p><strong>Now let&#39;s take a look at a <em>Function-based</em> component and spot the syntax differences</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*bzwi65MxQRdlYvNwwC2w5g.png" /></figure><p>The first thing you should immediately notice is there is no <em>Class</em>.</p><p>The second thing immediately after that is the way we initialize <em>State</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*i3BzPjobOcLAb_M_8Lm0tw.png" /></figure><p>Let’s break this down in simple terms:</p><ul><li>term is what your <em>State</em> currently is at any given moment. Instead of writing this.state.term it would just be term .</li><li>setTerm is essentially setState except with a more customized name. it works the exact same you can just choose what to name it.</li><li>useState is a hook. the purpose is to initialize what a certain key in <em>State</em> should be equal to. Since we are using a string we initialize an empty string.</li></ul><p>At first glance, <em>React Hooks</em> can seem a bit overwhelming, but its purpose is to make code look cleaner and more concise. I gave you an example of one hook so you can get the gist of the syntax and structure. There are other <em>Hooks</em> like useEffect , useReducer , useRef, etc. Hopefully, you can use this as a reference tool for future learning endeavors!</p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b48d9d2b6080" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/react-hooks-easier-than-you-think-b48d9d2b6080">React Hooks: Easier Than You Think</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming Slang Simplified!]]></title>
            <link>https://javascript.plainenglish.io/programming-slang-simplified-4e1776ec394b?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e1776ec394b</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Fri, 23 Jul 2021 01:39:23 GMT</pubDate>
            <atom:updated>2021-08-25T04:58:23.081Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*E4Hq8xGgQXjXYyfQhitgTQ.jpeg" /></figure><p>My primary goal in writing articles is to help fellow programmers understand concepts more easily by using just the right amount of depth while also keeping it simple. However, this article is a bit different. This article aims to help non-technical people have a basic understanding of the otherwise convoluted slang we programmers use. Let&#39;s get right into it.</p><p><strong>Programming Languages</strong>: Programmers, coders, software engineers, developers, etc. write in programming languages. Just like how humans communicate with one another with a multitude of different languages, a programming language serves to communicate with a computer and across networks.</p><p><em>Examples: Java, JavaScript, Ruby, Python</em></p><p><strong>Frameworks</strong>: Frameworks are innovated from programming languages. They essentially make writing in a language easier and are generally catered to specific sets of goals. One framework might be best suited for game development or mobile development while other frameworks are best suited for building websites. Frameworks require you to know a programming language for you to use them.</p><p><em>Examples: React(JavaScript), React Native(JavaScript), Node(JavaScript), .NET(C#), Angular(TypeScript), Rails(Ruby)</em></p><p><strong>Backend</strong>: A backend engineer(or developer) primarily focuses on managing and storing data. They use a <em>database</em> to store the data and write code so that the front-end developer can use it.</p><p><em>To make it easier to understand, think of the backend developer as someone who builds the car’s engine and systems attached.</em></p><p><strong>Frontend</strong>: A frontend developer focuses on displaying the data they get from the backend. They are in charge of how the webpage looks, feels, and interacts. One thing consistent with frontend engineers throughout web development is the use of HTML and CSS. HTML is in charge of displaying information while CSS is in charge of making things look pretty. A Framework like React which uses JavaScript will come in handy for complex user interactions.</p><p><em>Frontend developers are similar to the people in charge of designing the interior and exterior of the car while also making sure they have a wheel to turn and windows to roll down.</em></p><p><strong>Full Stack and Stack</strong>: a stack is a collection of languages used to build an application. There are quite a few popular stacks. <strong>MERN</strong> stack is one of them. MERN stands for <strong>M</strong>ongoDB, <strong>E</strong>xpress, <strong>R</strong>eact, and <strong>N</strong>ode. a Full-stack developer is someone who programs both the frontend and backend.</p><p><em>It is important to note that some languages/frameworks are better suited for the frontend and some are better suited for the backend.</em></p><p><strong>Databases</strong>: Databases are used to store data. A popular database is PostgreSQL which uses the SQL language. SQL is pronounced “sequel”.</p><p><strong>GitHub</strong>: GitHub is a website that is used to store your project online instead of solely on your computer. It is a cloud service. GitHub can also be used to collaborate with others online on the same project. Think of it like playing a single-player game compared to playing an MMORPG.</p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e1776ec394b" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/programming-slang-simplified-4e1776ec394b">Programming Slang Simplified!</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Async/Await: The Easy Way to Fetch]]></title>
            <link>https://javascript.plainenglish.io/async-await-the-easy-way-to-fetch-e490efd2e298?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e490efd2e298</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Tue, 20 Jul 2021 00:21:40 GMT</pubDate>
            <atom:updated>2024-09-23T10:22:47.624Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8vS21ULJDDzbPJNx" /><figcaption>Photo by <a href="https://unsplash.com/@baciutudor?utm_source=medium&amp;utm_medium=referral">Tudor Baciu</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>To understand Async/Await you first have to understand what promises are and how they work:</p><blockquote><em>JavaScript is single threaded, meaning that two bits of script cannot run at the same time; they have to run one after another. A Promise is an object that represents the eventual completion (or failure) of an asynchronous operation, and its resulting value. — freecodecamp.org</em></blockquote><p>To start, Think of a promise like a callback function that runs asynchronously within your JavaScript code. It does not have to wait on other code nor does other code have to wait on it. It executes independently on its own. It is used for when you need to do something that will take a long time in the background and you want to do something right after it is complete instead of making everything else wait.</p><blockquote><strong><em>💡 </em>Also, explore some of the most exciting additions to JavaScript in ES15:</strong></blockquote><p><a href="https://differ.blog/inplainenglish/ecmascript-2024-es15-unveiling-the-latest-javascript-features-db1ca2">ECMAScript 2024 ES15: Unveiling the Latest JavaScript Features</a></p><blockquote><em>👉</em> To read more such articles, <a href="https://differ.blog/"><strong>sign up for free on Differ</strong></a>.</blockquote><p>I think it is best to explain promises in a practical sense rather than doing what most tutorials will do:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*_P5OWiuJszXhWT44_fEDmw.png" /></figure><p>Here we have a function that is supposed to “load images” by fetching them from a URL assigned to a variable (IMG_URL). After “fetching” those images it returns a promise containing a response. The tricky part is figuring out how .then() works.</p><p>.then() returns a promise as well. It takes two arguments: callback functions for the success and failure cases of the Promise. The variable labeled r is the response of the initial fetch which is the previously completed promise.</p><p>as shown here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*wKbPfcbrrN23U0mmAPOloA.png" /></figure><p>Lets change console.log(r) to console.log(r.json()) . If you refresh the page you with see this in the console :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*eHQf-vkhw9f_AwChTESleg.png" /></figure><p>realize it says “Promise {&lt;pending&gt;}”. Now lets remove the console.log from console.log(r.json()) and refresh the page again. We fulfilled the promise and now we get an object which we labeled as “data”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*s4nDGKzmQxn1uJCWle54xg.png" /></figure><p>From here you can implement a callback function to manipulated the data by using “data” as the argument:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*fZgaz0A9MHCSJJ4CeOc0CQ.png" /></figure><p>Now that we somewhat understand promises and responses let&#39;s refactor that same chunk of code with Async/Await syntax:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*HYT4q3Mg69XkQB31S-R38g.png" /></figure><p>The async keyword lets javaScript know that the function is supposed to be run asynchronously. The await keyword is basically saying “wait until the following code is finished THEN execute the next thing”. This is exactly the same thing as we have been doing before, with just a little syntactical sugar added. It is important to have a basic understanding of fetch and .then() before delving into Async/Await.</p><p>Hope this helps.</p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://twitter.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a></li><li>Visit our other platforms: <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e490efd2e298" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/async-await-the-easy-way-to-fetch-e490efd2e298">Async/Await: The Easy Way to Fetch</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React: Controlled vs. Uncontrolled Forms]]></title>
            <link>https://javascript.plainenglish.io/controlled-vs-uncontrolled-forms-react-184a8b6d33c6?source=rss-a686ed2435a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/184a8b6d33c6</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Brian Rhodes]]></dc:creator>
            <pubDate>Mon, 19 Jul 2021 02:56:43 GMT</pubDate>
            <atom:updated>2021-08-25T11:51:54.871Z</atom:updated>
            <content:encoded><![CDATA[<p>At some point, you will come to terms that a lot of web design consists of forms. You can use forms for search bars, login, signup and the list goes on. Through learning React, you might have been told to write a single line of code in the input tag of your form that might have seemed redundant.</p><p>That line is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*OfEaHKdDfHmSypUQi5tpuA.png" /><figcaption>(“term” being inside your state)</figcaption></figure><p>Let&#39;s start with a full component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*2YhP-UAzACmqLSnc5O4i-w.png" /></figure><p>The entire idea of controlled components is to keep a single source of truth of where the data is stored and how to get it. If you know how <em>event listeners</em> and <em>state</em> work then you’ve most likely already been building most of what is considered a controlled component. When using React you want to keep things stored in React. Always avoid storing information in the HTML elements or more specifically the DOM. That is part of the purpose of using React’s state system. Not only does it handle user interactions, but it makes sure all information is stored within React. Otherwise, you would have to go into the DOM and manipulate things from there.</p><p>The most confusing part comes from the line that reads:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*OfEaHKdDfHmSypUQi5tpuA.png" /></figure><p>To start, the input tag already knows the value of the text you are typing. It is part of its job to store that information. However, as I said previously, we want to store all information in React, not the DOM. The purpose of value={this.state.term} is to default state to always be the value of the input. You are essentially overwriting the DOM information with the information in your state BUT both stored the same exact information you typed.</p><p>Why do this? Well “best practices” is one thing you can say. It’s probably something you’ve heard a lot with no explanation. You might think it’s just a pointless extra step but there is a reason…</p><p>This practice also allows you to do operations easier on your component. Since the final result always ends with the value equaling state, you can make changes to the data before it is pushed into the value. All you need are simple JavaScript methods. Whereas in an Uncontrolled component you would have to constantly reach out into the DOM and it could get a bit tricky.</p><p>Examples of this would be:</p><ol><li>Maybe you want to initialize this.state.term with words and not an empty string.</li><li>Maybe you want the input field to always be upper case or lower case so you put the methods at the end of event.target.value .</li><li>There are tons of things you can do. Give it a try!</li></ol><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=184a8b6d33c6" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/controlled-vs-uncontrolled-forms-react-184a8b6d33c6">React: Controlled vs. Uncontrolled Forms</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>