<?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 Connor on Medium]]></title>
        <description><![CDATA[Stories by Connor on Medium]]></description>
        <link>https://medium.com/@connorwcallahan?source=rss-54f8e5c3d782------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Connor on Medium</title>
            <link>https://medium.com/@connorwcallahan?source=rss-54f8e5c3d782------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 18:47:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@connorwcallahan/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[Using React State to manipulate CSS classes]]></title>
            <link>https://medium.com/@connorwcallahan/using-react-state-to-manipulate-css-classes-e85e1b1ced8d?source=rss-54f8e5c3d782------2</link>
            <guid isPermaLink="false">https://medium.com/p/e85e1b1ced8d</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[application]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Connor]]></dc:creator>
            <pubDate>Thu, 20 Jun 2019 20:24:07 GMT</pubDate>
            <atom:updated>2019-06-20T20:24:07.856Z</atom:updated>
            <content:encoded><![CDATA[<p>I picked up a neat trick the other day while re-configuring the navigation section on a React application I had been working on. The goal I was trying to achieve was switching the placement of the navigation bar from the top of the screen when a user is logged out and to the left-hand side when logged in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VqB9TAzgrW9Arn4VbDbdrw.png" /><figcaption>Logged Out</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J82PTkpqlZH0W7gsviJcWQ.png" /><figcaption>Logged In</figcaption></figure><p>The solution turned out to be relatively simple. Using a variable and setting it as a placeholder string dependent on which piece of state is currently active, I was able to interpolate it in the className.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7JbjboUS5Xqnf1NuPhTk_Q.png" /></figure><p>Now if the state for ‘loggedIn’ is true, the variable navShow will be hide and the div id will be navbar-show and vice versa for when a user is logged in. From here all I had to do was write the CSS for each id (navbar-hide and navbar-show). I used CSS grid to handle organizing the placement of the component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ico3lxqEnnKvEoi0qlvz8g.png" /></figure><p>This turned out to be a pretty resourceful tool and one that is incredibly easy to implement into any React project. Check out some of the links below for a more in-depth guide and information. Thanks for reading, have a great day!</p><p><a href="https://www.andreasreiterer.at/dynamically-add-classes/">How to dynamically add CSS Classes to React Elements using State &quot;</a></p><p><a href="https://reactjs.org/docs/faq-styling.html">https://reactjs.org/docs/faq-styling.html</a></p><p><a href="https://programmingwithmosh.com/react/multiple-css-classes-react/">https://programmingwithmosh.com/react/multiple-css-classes-react/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e85e1b1ced8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create informative dynamic charts using .reduce() and Chart.js]]></title>
            <link>https://medium.com/@connorwcallahan/how-to-create-informative-dynamic-charts-using-reduce-and-chart-js-c874c3a1cd90?source=rss-54f8e5c3d782------2</link>
            <guid isPermaLink="false">https://medium.com/p/c874c3a1cd90</guid>
            <category><![CDATA[chartjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reduce]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[charts]]></category>
            <dc:creator><![CDATA[Connor]]></dc:creator>
            <pubDate>Wed, 12 Jun 2019 21:19:52 GMT</pubDate>
            <atom:updated>2019-06-27T13:04:51.438Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to create dynamic charts using .reduce() and Chart.js</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UcgEeR2mlQ1ybsIz9KNadA.png" /><figcaption>React App (<a href="https://speculate.netlify.com/">https://speculate.netlify.com/</a>)</figcaption></figure><p>Rendering charts in an application to display dynamic information is a great way to provide users with a visual representation of data. Chart.js is a library that makes it easy to render whatever type of graph might best suit your needs with a great degree of flexibility(pie-chart, line-chart, bar graph, etc.).</p><p>First install chart.js using yarn or npm.</p><pre>yarn add react-chartkick chart.js</pre><p>Next specify which types of charts you want to import in the component.</p><pre><strong>import</strong> { LineChart, PieChart } <strong>from</strong> &#39;react-chartkick&#39;</pre><p>When fetching data from an external source or API, it is likely the data may not be presented in the best way to suit your charting needs. An example of this I encountered while developing an application to display stock information was that the data I needed to access was accessible, but existed within the same object as relative keys to different values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*GYAxfQpEnEjRYE2ZxsaEXQ.png" /><figcaption>Investor Exchange API</figcaption></figure><p>Rather than having a two separate key values (date, price), using the reduce method we can re-formulate the data so that the date becomes the key to the value of price.</p><p>The reduce method provides a simple way to take an array of values and combine them into one value. In the method outlined below a function is called within reduce with a collector and value.</p><pre>data={this.props.chart.reduce(function(collector,value){<br>               collector[value.date] = value.close<br>                return collector<br>                } ,{})<br>              }</pre><p>The collector retains the the new associated values from the array and they are returned as the newly configured object.</p><pre>reconfigured object to chart -&gt; {date : 185.72}</pre><p>Then we can use this re-configured key-value pair to display a chart of the relative price over a given period of time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*tTj6tIKcFcvsGYKNc2D5tA.png" /><figcaption>chart displaying price over time</figcaption></figure><p>You can check out some examples of dynamic charts I have created using react, chartkick, and chart.js in my application Speculate (built for my final project in completion of the Flatiron School Software Engineering intensive). Feel free to follow the link -&gt; <a href="https://clever-archimedes-2b5cd4.netlify.com/">https://clever-archimedes-2b5cd4.netlify.com/</a> . Enjoy!</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce">Array.prototype.reduce() - JavaScript | MDN</a></li><li><a href="https://chartkick.com/react">React Chartkick - Create beautiful JavaScript charts with one line of React</a></li><li><a href="https://www.chartjs.org/">Chart.js</a></li><li><a href="https://www.connorwcallahan.com/">Home</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c874c3a1cd90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revising my portfolio website with React and Gatsby.js]]></title>
            <link>https://medium.com/@connorwcallahan/revising-my-portfolio-website-with-react-and-gatsby-js-6bd7c3e63f18?source=rss-54f8e5c3d782------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bd7c3e63f18</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[netlify]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[gatsbyjs]]></category>
            <dc:creator><![CDATA[Connor]]></dc:creator>
            <pubDate>Sun, 26 May 2019 14:30:14 GMT</pubDate>
            <atom:updated>2019-05-26T14:31:21.904Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Glbi9MHoAP8pn0hNyo2aeg.png" /><figcaption>the homepage of my new website</figcaption></figure><p>I knew that one of the most important ways to demonstrate my skills as a recent graduate of a software engineering bootcamp would be to create a portfolio website to host my projects. While I did have some major ambitions for my site, I also knew creating the perfect website wouldn’t happen overnight so I created something within a reasonable goal and time frame to deploy. I figured it was better to have something ready that was simple and imperfect rather than nothing at all.</p><p>In the end I hacked together a site with just enough html, css and javascript to display a project gallery on a single page. I also placed a few links to relevant pages, my email and social media. While this was a great exercise in writing code from scratch my site was terribly inefficient and would be a total nightmare if I wanted to build or add anything in the future.</p><p>A few weeks had passed and I just couldn’t stand looking at my own website anymore (honestly it was pretty cringe-worthy). It was finally time to roll up my sleeves, do some planning and make a great site! After doing some preliminary research I found out about a relatively new plugin for React to generate static sites called Gatsby. Gatsby provided me the available to connect connect to my site without developing a backend. This also meant I could more easily develop adaptable styles for pages and components to easily add new features to the site over time.</p><p>Getting started with Gatsby ended up being a breeze and once installed from npm, there are some tools in the CLI to use. Similar to create-react-app, gatsby new is used to create a folder with all the relevant starter files you will need for your site. Right out of the box you may see a few things familiar if you have used React before and a now some extra goodies included with Gatsby.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jUzgDE_cL0SWfifXgtqHcg.png" /></figure><p>One aspect of Gatsby I immediately liked was the built in &lt;Link /&gt; component to navigate between internal pages. This enables a performance feature called pre-loading which ensures the resources are fetched by the time the user navigates with this component.</p><p>Another part of my site revision that made everything more manageable was importing site content/data in from local src files as an object. For example I had formerly listed all the headers, links, descriptions and images to my projects gallery within my code. The result was painful to look at and difficult to edit. Now I can simply import the file projects.js with an array of objects with my all necessary data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtJz6dRUfT5ukfp4yS0uNg.png" /></figure><p>Once the file is imported I can then assign the data to a variable and loop through the array of objects to render my list of projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wWSu2aNwzUYQCgCF5iG_OA.png" /></figure><p>Anytime I want to add, swap or edit one of my projects I only need to change one file and do not even have create any additional html tags or content. Having a small amount of source code to initiate broad changes in content across a static site is a huge time-saver. This was extremely useful especially since I wanted to design the layout of this website to my preferences and without using a style library. Gatsby handles configuration of the site the same way is easily accessible to add some nice details like a favicon, site description, title, etc. Very practical for sites ultimately deployed and that may need SEO.</p><p>I have barely scratched to surface of what Gatsby can do and am looking forward to utilizing more plugins, adding new features and creating additional content for my website. Checkout gatsbyjs.org for more information and documentation on how to use Gatsby with react. There are some terrific examples featured in the showcase section of the site to inspire and motivate your next great website!</p><ul><li><a href="https://www.gatsbyjs.org/docs/quick-start/">Quick Start</a></li><li><a href="https://www.netlify.com/">Push your ideas to the web | Netlify</a></li><li><a href="https://scotch.io/tutorials/deploying-your-first-gatsby-site-to-netlify">Deploying Your First Gatsby Site to Netlify</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bd7c3e63f18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an easy to use monthly budget calculator with React]]></title>
            <link>https://medium.com/@connorwcallahan/building-a-quick-and-easy-monthly-budget-calculator-with-react-29c6dc86d211?source=rss-54f8e5c3d782------2</link>
            <guid isPermaLink="false">https://medium.com/p/29c6dc86d211</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Connor]]></dc:creator>
            <pubDate>Mon, 22 Apr 2019 23:41:34 GMT</pubDate>
            <atom:updated>2019-07-03T11:17:05.732Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J33xU07Rs19VrMYs3yutrA.png" /><figcaption>monthly budget calculator, built with React</figcaption></figure><p>I recently decided to attempt building a completely new application to see if I could reasonably reach a basic MVP (minimum viable product) I had outlined within the span of a weekend. For some time I had envisioned creating a simple budget calculator and this seemed like as good project to experiment more with React and build an easy-to-use, fun and (hopefully) useful tool.</p><p>As a person who is visually inclined I always like to do some wire-framing to get my ideas down for how the application should work before I start coding. Using a pencil and paper helps guide my decision making when it comes to the finer details such as the number of components/containers, state, etc. Since I wanted the application to be as simple as possible my approach was fairly minimal and left room to be built upon if I felt like it later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dp8dC-bxX0jijOrrAy9sTA.jpeg" /><figcaption>I’m no artist, but it does the trick</figcaption></figure><p>Once I had a basic idea of the course of events that I wanted to occur in the application, I set out to making a few of the components I knew that I would need. Since the application is so simple having more than a couple components would be overkill, but to keep things necessary I decided to separate the forms for income and expenses. This way I wouldn’t have a lengthy form in my most active portion of code and instead tucked away and nicely nested as a child of the Calculator component. (the component can be thought of as presentational and only invokes functions in Calculator.js)</p><p>The first obstacle I decided to tackle was having the income tax update dynamically with the income input. This ended up being the easiest task to complete and while the result wasn’t the most beautiful few lines of code I have written, it certainly got the job done. Basically the function would be triggered by the onChange event on the form. Based on the value inputted a conditional statement the Federal income tax brackets would evaluated as percentage of tax to deduct. When the function is executed, state is set for balance(gross monthly income), tax(percentage based on income) and net(the difference between the gross income and tax).</p><p>Once I had calculated the income I could now start finding a way to deduct all of the expenses. (housing, utilities, transportation, etc.) This ended up being the trickiest part of the application, but once I had nailed down the right data structure for state it became much simpler. Initially I had considered creating state for each expenses. The problem would be updating the value dynamically and filtering out the parts of state I did not want to update at the same time (the expense actively being updated). What I decided doing after some trial and error was creating an array of objects in state, with an attributes for the type of expense and cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*hcIcyFgtT3VeQ4h6Bx-dnA.png" /></figure><p>Now that I had a expenses as an object in state I could filter through, I had to connect the onChange event to the expenses form and update each expense. I used the findIndex method to determine which expense object to update in state. Instead of actually “updating” the object, I used Object.assign to create a new object and then re-insert it into the expense array using .slice with the index I retrieved in the last method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*zyhpJ7F5XgNom1yB0QNKsw.png" /></figure><p>The expense array is now updated with the expenses inputted on the form, but the remaining balance has yet to be updated. In order to update the balance I invoke a function renderBalance every time the form changes, passing in the id and value of the current expense. (an aspect of the project I would definitely change if I come back to it with more time) In the renderBalance function I filter through the expenses array using the id passed in, to determine which expense to exclude from the total. Then the value originally passed is added to the total (the total being every other expense and the value being the current updated expense). This value is ultimately used to set the balance in state and render the change on the page.</p><p>You can follow this l<a href="https://vimeo.com/331885902">ink</a> to view a demo of the application. (stay tuned for a live version on heroku). Thank you for taking the time, hope you enjoyed! Here are some of the references below of pages and code I used and found extremely useful while building this app.</p><ul><li><a href="https://www.connorwcallahan.com/">Home</a></li><li><a href="https://github.com/Connor-Callahan/budget-me">Connor-Callahan/budget-me</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign">Object.assign() - JavaScript | MDN</a></li><li><a href="https://www.robinwieruch.de/react-state-array-add-update-remove/">How to manage React State with Arrays - RWieruch</a></li><li><a href="https://medium.com/@mirthfulnahid/using-the-spread-syntax-in-react-js-to-set-state-array-of-object-c47c631f64b0">Using the Spread syntax in React Js to set state array of object</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29c6dc86d211" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>