Logo

Category: Web Development

Pragmatic uses for React Context

July 24, 2019
chains-perspective
The purpose and use case for the React Context API long eluded me. I was familiar with what it did in principle, but struggled to find a use case for it. The Context API can solve some unique problems such as: grouping localized text strings and creating a language provider. In this post I share how the Context API can help solve these problems, as well as some sample code. According to the React docs: Context provides a way to pass data through the component tree without having to pass props down manually at every level Passing Localized String Props Localized applications bring a host of various complexities, one of which being an increase in the amount of props for localized text. The removal of any hard coded text strings can quickly…
Read More

How to Resolve Accessibility Issues with React Helmet

May 28, 2019
an open book with reading glasses and a cup of coffee nearby
The attribute is an essential part of the HTML element. It identifies the main language of the document's content. This is used by screen readers to determine the pronunciation of words. Screen readers have a default language setting, but will respect the language specified in the element if they differ. However, if this attribute is missing, and the language of the document is different than the screen reader's settings, the user will receive a subpar experience with incorrect pronunciations. For more information on the accessibility of this attribute, check out Deque University's detail page. React Helmet and JSX In many React development scenarios, the shell HTML template is not immediately available to the developer. In other…
Read More

Shaping JavaScript Usage with ESLint

May 23, 2019
A person shaping clay by hand on a pottery wheel
I have used ESLint for a long time, often extending the recommended rules from various plugins. I only read a rule’s documentation if I wasn’t sure why it was being flagged in the linter. Last month I read through and manually set 381 ESLint rules, reading the accompanying docs for each rule. I discovered that ESLint is more than enforcing community guidelines on code quality. It also helps to shape use of the language as a whole and through project specific rule usage. Greater control for team objectives There are a number of rules the recommended configurations of ESLint or various plugins do not enable by default. These rules serve specific needs of a given project. They can be enabled and configured on a per project basis and provide…
Read More

How to Manage Snapshots with ESLint

March 18, 2019
Individual holding a camera lens with mountains and lake in the distance
Jest Snapshots can be a valuable utility for monitoring code changes for UI components. They can also become a scourge if they become too large. The line between the two isn't always clear. Snapshots don't offer a clear mechanism to determining how large they are. This makes it easy to create large snapshots that are hard to diff. The likelihood of a thorough review on a snapshot diff decreases in relation to the size of the snapshot. I have both observed and committed broken snapshot updates into repositories as part of a branch. The danger lies in making intentional changes to a particular feature and updating the snapshot without checking for other breakages. If the snapshot diff is large, it will likely not receive as thorough a review…
Read More

Iterating Quickly with GraphQL and Gatsby

March 11, 2019
Grey geometric triangles
Over the past month I have been adding features to the blog that I had put off for long enough. As I aim to write more, it was time to address some glaring omissions in my initial implementation. This included adding proper category and tag pages, post metadata, and other small features. Gatsby's tight integration with GraphQL enabled quick iteration and development of these new features. Some features required as little as adding a utility field to a GraphQL query to implement. Data selection per query One of GraphQL's core features is the ability to select only the required data. A selection set is the specific data requested within a given type. GraphQL uses a declarative data structure. This means that the API consumer specifies the…
Read More
2022 Skyler Lemay. All Rights Reserved.