We love reading, watching, and listening to constantly update our skills and learn new perspectives. Here are some of the exciting pieces we learned from this month.
In this talk, David Khorshid discusses the awkward undesirable aspects of using
useEffect to handle side effects. Specifically,
useEffect's proclivity for entering infinite loops and React 18 running
useEffect twice on mount by default ????. He suggests several alternatives to use in react projects which he feels are less treacherous, including options like using state machines/external data stores to handle side effects or using
React.Suspense as an alternative to fetch data early.
2022 Ruby on Rails Community Survey Results
Tips for Using FactoryBot Without an ORM
As we continue to level-up our skillsets as developers in Rails, the utility of POROs (Plain Old Ruby Objects) becomes more apparent and appealing. Sometimes, the business object(s) you create do not require persistent storage to a database and are, therefore, outside of the scope of an ORM (Object Relational Mapper) like
ActiveRecord. But how do we maintain simplicity in our test suite and continue to leverage helpful testing libraries like FactoryBot without one? This instructional article explores how to implement factories for POROs including common pitfalls, building nested resources, and factory linting.
The State of CSS 2022
It's a well-known fact that our industry is ever-changing - even older technologies like CSS are (thankfully) constantly evolving and being improved upon to support this exciting new era in web development. Rarely, however, do we get access to a compiled list of updates that occurred over the course of the year _and_ upcoming work for our favorite tech. Enter "The State of CSS 2022". This was presented as part of Google IO 2022 and serves as a jumping-off point to understand today's CSS features and get excited about tomorrow's!
Presenters Compared to Decorators, Strategies, and Composites
There are several ways a Ruby class can be extended. The way in which we extend it will tell us how we want to identify our extension. Are we adding functionality? Are we adding presentational elements? Are we adding both? Here's an old-but-still-relevant post from Thoughtbot on a few of the choices.
Testing Techniques: The I/O Table
Testing complex SQL queries in our Rails applications can be _almost_ as challenging as writing them. The correctness of a test is one thing, but ensuring that the test is readable and maintainable is a completely different animal, because tests in this context often require extensive setup and result lengthy and confusing outputs. This article demonstrates testing an SQL query via an input and output (I/O) strategy. The author's approach allows us to use raw data to forgo complicated setup processes and to make the test(s) more clear. The output even looks like tabular data - neat!
How to Access Hash Values Like Methods in Ruby
Learning about new ways to manipulate data in Ruby is always fun. This article details a way to access hash values as if they were methods via the
ActiveSupport::OrderedOptions class. Initially, it wasn't clear why someone would reach for this over the default syntax, but the author pointed out that syntax can be helpful in keeping configuration files clean and readable. Apparently, this can be observed in the wild in the Propshaft (an asset pipeline library) codebase, which uses it to define
Serialize Ruby data structures into JSON, XML, and YAML, and back again.