<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>React on Tim Loughrist</title><link>https://timloughrist.com/category/react/</link><description>Recent content in React on Tim Loughrist</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Tue, 04 Apr 2023 17:48:43 +0000</lastBuildDate><atom:link href="https://timloughrist.com/category/react/index.xml" rel="self" type="application/rss+xml"/><item><title>Action Cable: simple implementation</title><link>https://timloughrist.com/2023/04/04/action-cable-simple-implementation/</link><pubDate>Tue, 04 Apr 2023 17:48:43 +0000</pubDate><guid>https://timloughrist.com/2023/04/04/action-cable-simple-implementation/</guid><description>&lt;p&gt;&lt;a href="https://guides.rubyonrails.org/action_cable_overview.html"&gt;Action Cable&lt;/a&gt; is a framework to allow multiple clients to receive seamless, simultaneous updates from a Rails server. If you have an application where changes submitted by one user should be seen immediately by all users without a refresh, Action Cable might be the solution you’re looking for.&lt;/p&gt;&#10;&lt;p&gt;In my case, I was developing a &lt;a href="https://github.com/tloughrist/capstone-frontend"&gt;two to four player variant of Chess&lt;/a&gt; where all players needed to be able to see every move made by the other players. Since all players are being served by the same server, they could see the new state of the board by refreshing their page, but that is clearly not an ideal way to handle the issue.&lt;/p&gt;</description></item><item><title>Building login functionality with React</title><link>https://timloughrist.com/2022/10/06/building-login-functionality-with-react/</link><pubDate>Thu, 06 Oct 2022 20:04:33 +0000</pubDate><guid>https://timloughrist.com/2022/10/06/building-login-functionality-with-react/</guid><description>&lt;p&gt;&lt;em&gt;Disclaimer: the information below should be used as an illustration only. For secure login functionality, you are best served by using a third-party authentication service, like &lt;a href="https://www.okta.com/"&gt;Okta&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;Saving user data in order to customize user experience is a common feature in web apps. Implementing this feature requires the ability to:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Allow users to input a username and password combination&lt;/li&gt;&#10;&lt;li&gt;Check that combination against the combinations associated with user data in a database&lt;/li&gt;&#10;&lt;li&gt;If the combination is found, the user data is stored in a state and used to customize user experience&lt;/li&gt;&#10;&lt;li&gt;If the combination was not found, the user would be alerted that the combination was incorrect and the user would not be able view user data&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;I’m going walk through two different ways to build out this feature using React. The first method only makes use of state while the second uses the browser’s session storage to hold a login token.&lt;/p&gt;</description></item><item><title>Persistent path-specific styling in React</title><link>https://timloughrist.com/2022/10/06/persistent-conditional-styling-in-react/</link><pubDate>Thu, 06 Oct 2022 12:52:58 +0000</pubDate><guid>https://timloughrist.com/2022/10/06/persistent-conditional-styling-in-react/</guid><description>&lt;p&gt;&lt;strong&gt;The situation&lt;/strong&gt;: you’re building a single-page application in React using client-side routing.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;The goal&lt;/strong&gt;: to apply styling to an element as long as a user is on a particular “page”.&lt;/p&gt;&#10;&lt;p&gt;Imagine that you have a navigation bar across the top of your app with navlinks to the app’s various “pages”. You want the navlink for the current page to stand out so users can quickly see where they are in the app.&lt;/p&gt;</description></item></channel></rss>