<?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 Daniel Chukwuemeka Arisa on Medium]]></title>
        <description><![CDATA[Stories by Daniel Chukwuemeka Arisa on Medium]]></description>
        <link>https://medium.com/@danielcarisa?source=rss-3083ede3cf92------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*adz96972QMgWCHho</url>
            <title>Stories by Daniel Chukwuemeka Arisa on Medium</title>
            <link>https://medium.com/@danielcarisa?source=rss-3083ede3cf92------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:12:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danielcarisa/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[How to fetch API Data in React like a coding veteran]]></title>
            <link>https://medium.com/@danielcarisa/how-to-fetch-api-data-in-react-like-a-coding-veteran-3f9b73f1bfcd?source=rss-3083ede3cf92------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f9b73f1bfcd</guid>
            <dc:creator><![CDATA[Daniel Chukwuemeka Arisa]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 12:26:18 GMT</pubDate>
            <atom:updated>2022-10-25T14:11:01.750Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*-g0ET91zfzWzcBqU1A77YA.jpeg" /></figure><p>As my time in my coding bootcamp begins to come to a close, I begin to find myself thinking about the way I thought about things when I first started this journey.</p><p>In the beginning fetching data was an intimidating task. Getting it to render was even more intimidating. Now that I have it down let’s review the basics.</p><p>The first step is to add the import statement at the top.</p><pre>import React, { useEffect, useState } from “react”</pre><p>The next step is inside the App.js or wherever you’re passing props down from add a state hook that will hold our data in this case we will use users as an example.</p><p>When you add the fetch function you should end up with something that looks like this.</p><pre>const [users, setUsers] = useState([])</pre><pre>import React, { useEffect, useState } from &quot;react&quot;<br><br>const App = () =&gt; {<br>  const [users, setUsers] = useState([])<br><br>  const fetchUserData = () =&gt; {<br>    fetch(&quot;https://jsonplaceholder.typicode.com/users&quot;)<br>      .then(response =&gt; {<br>        return response.json()<br>      })<br>      .then(data =&gt; {<br>        setUsers(data)<br>      })<br>  }<br>  <br>  return (<br>    &lt;div&gt;<br>      Hello World<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>After this you can go on use the useEffect to hold the fetched data in state</p><pre>useEffect(() =&gt; {<br>  fetchUserData()<br>}, [])</pre><p>But for the most part this is the “fetch on render” method used. Meaning that the request is triggered when the component first renders. But I propose another way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*JLMrfMQ5BUoMDIEF3NsOUg.gif" /></figure><p>The other method I propose is the <strong>Suspense Method</strong>.</p><p>Suspense is all about maintaining a consistent UI in the face of async dependencies. Suspense helps you handle asynchronous operations easily. Suspense delays the execution of the entire tree until the promise inside the component is either fulfilled or rejected. It allows you to notify users that the expected data should be displayed.</p><p>We begin with fetching earlier in the function.</p><pre>const promise = getUsers();<br><br>const DataFetch = () =&gt; {<br>  // ...<br>  <br>  React.useEffect(() =&gt; {<br>    promise<br>      .then(data =&gt; {https://jsonplaceholder.typicode.com/users}<br>      .catch(error =&gt; {https://jsonplaceholder.typicode.com/users} <br>  }, []);<br>  <br>  // ...</pre><p>Our code will now look like this.</p><pre>const resource = createResource(getSomething());<br><br>const FetchData = () =&gt; {<br>  return &lt;p&gt;{resource.read()}&lt;/p&gt;;<br>}<br><br>const App = () =&gt; (<br>  &lt;ErrorBoundary fallback={&lt;p&gt;Something went wrong&lt;/p&gt;}&gt; <br>    &lt;Suspense fallback={&lt;p&gt;Loading...&lt;/p&gt;}&gt;<br>      &lt;FetchData /&gt;<br>    &lt;/Suspense&gt;<br>  &lt;/ErrorBoundary&gt;<br>);</pre><p>We wrap our component up with the &lt;Suspense /&gt; wrapper. When we do this what changes is that it must return the resource if it’s available, it must throw an error if something goes wrong, and it must throw a Promise if the resource is not yet resolved.</p><p>So in all, suspense allows you render component trees concurrently while loading data. If you have two component inside Suspense; both components will start rendering in parallel, instead of holding both component trees, the data required for each component will be loaded in parallel which improves performance and user experience.</p><p>If I’ve learned anything in these last few weeks it’s that coding is about innovative thinking. This method is far from mature and it is still uncertain what the best practices for data fetching will end up being. React Suspense for Data Fetching provides an alternate and debatably more efficient way to fetch data in React.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f9b73f1bfcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Seeding Data with Faker as illustrated by Jerry.]]></title>
            <link>https://medium.com/@danielcarisa/seeding-data-with-faker-as-illustrated-by-jerry-d4278a05e094?source=rss-3083ede3cf92------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4278a05e094</guid>
            <dc:creator><![CDATA[Daniel Chukwuemeka Arisa]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 04:38:52 GMT</pubDate>
            <atom:updated>2022-10-04T14:19:31.045Z</atom:updated>
            <content:encoded><![CDATA[<p>So you’re working on your Ruby project. You’ve set up your tables, completed your migrations, and now you want to add some seed data information.</p><p>So you start making your seed data…</p><pre># db/seed.rbputs &quot;Seeding...<br>&quot;Subscribers.create(name: &#39;Devin&#39;)<br>Subscribers.create(name: &#39;Jasmine&#39;)<br>puts &quot;Seeding done.&quot;</pre><p>Db/migrate</p><p>and you begin to notice how tedious it will be…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*d9jUnnrMkwL_khEKC_RGYQ.gif" /></figure><p>Then in your irritation, you remember Faker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*gH1RqIZWAUnBzqTob-qSRw.gif" /></figure><p>Faker is a Ruby gem that comes with an array of generators that allow you to create fake data such as names (first name, last name), email addresses, phone numbers, Twitter handles, job titles, etc.</p><p>There are <strong>165 different namespaces </strong>to chose from with all their own attributes!</p><p>To start off you install it by running</p><pre>gem install faker</pre><p>Then in an action that reminds you of importing in React, you add a line that says</p><pre>require `faker`</pre><p>at the top of your seed data.</p><p>Now Faker is all set up and your existential crisis is now averted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*QBU-DLkZ4KRZwnjXbqguxw.gif" /></figure><p>Now you can do something like generate fake data for 20 subscribers without breaking a sweat. The data can have multiple categories such as names, addresses, phone numbers, etc.</p><pre>20.times do <br>User.create(name: Faker::Name.name<br>            address: Faker::Address.street_address<br>            job: Faker::Job.title<br>            phone_number: Faker::PhoneNumber.phone_number)<br>end</pre><p>You’d loop through the Faker data generator how ever many times you please to create that many data entries and this code will create 20 subscribers all with different data that you can effectively test your methods with as you make your server work.</p><p>For more information go to the <a href="https://github.com/faker-ruby/faker">faker GitHub repo</a>.</p><p>You are now a very happy Jerry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*Qj28mPTKvRFOCj1M4jSQvA.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4278a05e094" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I would think about React were I to start again.]]></title>
            <link>https://medium.com/@danielcarisa/how-i-would-think-about-react-were-i-to-start-again-bfcd174699ba?source=rss-3083ede3cf92------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfcd174699ba</guid>
            <dc:creator><![CDATA[Daniel Chukwuemeka Arisa]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 13:35:26 GMT</pubDate>
            <atom:updated>2022-09-12T13:51:51.420Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>If at first you don’t succeed, Try, try again — Edward Hickson</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*w1aeVuLWEaDDRUim.gif" /></figure><p>Phase two of coding school in the bag. React is a mental trek but a necessary one. If I were to start all over, if I could talk to my past self here’s what I’d say.</p><h4>Components and props are your friends</h4><p>I admit when first starting React the code looked like a foreign language. Props are the tools used to pass information between components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*vtz59azeZHu1RcbkWGm0Aw@2x.jpeg" /></figure><p>Props can be functions or objects. For example you could pass a prop that is an array of data on dogs. The array could contain information such as the name of dog, it’s age, it’s breed, an image, etc. The information would be passed down from the parent component down to the child. You can also pass down functions and in my experience the functions are normally passed down are normally used to set or render objects to the screen. In the case of our dog example I would name the function something like renderDogPictures.</p><h4>Remember structure it’ll keep you organized</h4><p>Sometimes when handling a lot of components the information gets all jumbled up. It’s better to start with one task at the top of the component tree then move to the next. I try to add extra space in between different variables that are doing different things, and I especially add a lot of space between different USESTATE and USEFFECT functions.</p><h4>USESTATE and USEFFECT</h4><p>These two concepts have been the hardest for me to learn. First things first always remember to import useState with a bracket like so {useState}. That will save you a lot of pain. Next always remember that to initialize the useState method. You need to declare a variables. For instance something like</p><p>Const [dogs , setDogs]= UseState()</p><p>The useEffect method helps you tell the component to perform an effect after it’s rendered. Like useState, useEffect accepts a function as parameter, and an array as a second parameter that contains the state items for rendering and re-rendering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*VOwkU8cdbWLK9s6WBRgSzA@2x.jpeg" /></figure><p>Always remember the useState and useEffect go together separated by a comma at the top of the page like so.</p><h4>Fetching isn’t as scary as it looks</h4><p>The Fetch API provides a system of retrieving resources across a network. It normally looks like this, don’t be afraid to google the structure. Pride will get you no where.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*bxydPJGzb-SKSbNk.png" /></figure><p>Use the useState hooks (which are functions that allow you to “hook” into state). Alway remember to add the empty ([]) as a second so that the code only runs the once. Add the .then and the data from the url will be passed onto the variable. To separate the information either use a .map, .filter, .reduce, but that information for the next edition.</p><p>Learning new concepts can be hard, but breaking the concepts into small digestible pieces is how you begin to understand them. I think that you need to practice the code over and over until it starts to make sense and you begin to actionably use the code as a tool, versus just regurgitating into the code editor. Keep coding it out, you got it dude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*jgqXb7rQ7RdmvlKB.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfcd174699ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginners Beginner’s Guide to Scope In JavaScript: Part 1]]></title>
            <link>https://medium.com/@danielcarisa/a-beginners-beginners-guide-to-scope-in-javascript-part-1-36b2d9469a15?source=rss-3083ede3cf92------2</link>
            <guid isPermaLink="false">https://medium.com/p/36b2d9469a15</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Daniel Chukwuemeka Arisa]]></dc:creator>
            <pubDate>Fri, 05 Aug 2022 11:38:11 GMT</pubDate>
            <atom:updated>2022-08-05T13:29:05.596Z</atom:updated>
            <content:encoded><![CDATA[<p>So you finally mustered up the courage to take the first step toward breaking into the tech world. You scraped together your shekels, joined a Bootcamp, blasted through the pre-work, and now you’re on your way to fulfilling your insomnia-ridden Mr. Robot fantasies. But wait.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*-T2bDQZO1JRC0aXiRxwUyQ.gif" /></figure><p>As you take your first lab challenge you notice that as you console log your variable, JavaScript throws ReferenceError: message is not defined.</p><p>And you wonder to yourself, what happened? From one beginner to the next, it can be frustrating, but alas there is hope. Let me introduce you to the world of scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*BqtXqF0INn0DBLp1YoB8dw.gif" /><figcaption><strong>Patrick embarking on the beautiful journey of learning scope</strong></figcaption></figure><p>Scope is an important concept for understanding how variables are available in a program. Scope is either global or local. Global variables can be accessed and modified by every function in an application, while local variables are accessible and can be modified only within the function in which they were declared.</p><p><em>For example</em></p><p>In your lab you have a function declared in your global scope.</p><pre>function myFunc() {<br>  return 42;<br>}</pre><p>If you have a second function under it, like so.</p><pre>const myVar = myFunc() * 2;</pre><p>You are able to “reference” and “invoke” myFunc()because both functions are in the same scope!</p><p><em>Conversely</em></p><p>If you have a similar scenario.</p><pre>function myFunc() {<br>  const myVar = 42;<br>}</pre><p>And you want to achieve the same outcome by multiplying myVar by 2 like so.</p><pre>myVar * 2;</pre><p>JS will throw you a // Uncaught ReferenceError</p><p>Because myVar is not defined within the scope of myFunc().</p><p>Congratulations you now understand the very basics of scope.</p><p>The next step is understanding <em>block scope. </em>In JavaScript, all code blocks use braces { } to enclose their code. Variables defined inside a code block will only exist within that block, which is the case for if, for, and while statements.</p><pre>if (condition) {<br>  let z = 45<br>  console.log(z) // 45<br>}<br>console.log(z) // ReferenceError<br><br>for (let i = 1; i &lt; 2; i++) {<br>  const a = 35<br>  console.log(b) // 35<br>}<br>console.log(b) // ReferenceError</pre><p>These give a reference error because variables z and b are not within their respective scopes.</p><pre>while {</pre><pre>const message = &#39;Hi&#39;;</pre><pre>console.log(message); // &#39;Hi&#39;</pre><pre>}</pre><p>In this case, this “while” condition for the variable message is within the scope of the console log.</p><p>You now have a beginners beginner’s guide to scope in JavaScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*BfrkihSPVL6WHkhNPVggkQ.gif" /></figure><p>This is part one of this series and we will continue to learn about scope when we meet again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36b2d9469a15" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>