At The Gnar we are always reading, watching, and listening in order to keep our skills sharp and our perspectives fresh. Here are some of the resources we learned from this month.
ComparisonValidator
Gone are the days when we need to write custom validators in Rails to determine if a start date begins before an end date! Back in 2021, the ComparisonValidator
was added to Rails 7. While useful for solving the date comparison example above, that’s not all it can do! It can also compare strings, and it allows for the flexibility of custom comparisons.
Active Storage Can Pre-Process Variants
Earlier this month Rails added a feature allowing Active Storage variants to be pre-processed up front by adding preprocessed: true
to the variant definition. This makes the attachment ready to serve from the outset, rather than requiring the variant to be prepared/transformed on the fly.
JavaScript’s findLast()
and findLastIndex()
There are a few new Array
functions included in ES2023, findLast()
and findLastIndex()
. The exciting piece is less about what these functions do (you can probably figure it out from the names) and more about the convenience that they provide. As a Rubyist by trade, I am used to a super developer-friendly experience when it comes to the readability, and accessibility of functions so it’s great to see these being added to JavaScript - even if it took until 2023. 😉
Partial Renders in Rails
Partial rendering allows you to create a consistent template with different sections, for example “title”, “body”, and “footer.” Then the templates can define content for each of those sections without having to know anything about the layout of the root template.
React.FC
Removed From create-react-app Base TypeScript Template
If you build React apps with TypeScript, you're certainly used to seeing and using the React.FC
(or React.FunctionalComponent
) type at the declaration of your functional components. The folks maintaining create-react-app have decided to remove this type from their template as they believe it is more harmful than helpful. I tend to agree, particularly around the implicit definition of children
.
Contributors:
- Ethan Fertsch
- Steve Zelaznik
- Taylor Kearns
Learn more about how The Gnar builds software.