Skip to content

Repository files navigation

Snippet-Showoff

A few code snippets to show off some of the work I have done.

claimsTableReducer

The claimsReducer code is a TypeScript function that showcases my ability to write clean, maintainable, and efficient code. It implements a reducer pattern to be used alongside React's useReducer hook, specifically for handling claims in an application.

The reducer follows best practices by using TypeScript's type annotations for function arguments and return values, ensuring type safety throughout the codebase. It effectively handles different actions such as setting claims, changing the active tab, and clearing claims, demonstrating my proficiency in managing complex state transitions.

The code leverages the power of JavaScript's object spread syntax to update state immutably, preserving the integrity of the original data. By utilizing this approach, I ensure predictability and avoid unintended side effects.

isPersonalBest

This TypeScript function, isPersonalBest, highlights my ability to write clean, concise, and readable code that follows good software design principles. The function demonstrates my proficiency in TypeScript, using types for function arguments and return values to ensure type safety. It also clearly exhibits the Single Responsibility Principle as it is focused on determining whether a logged set is a new personal best for weight, one-repetition maximum (1RM), or volume.

The logic within the function shows how I handle calculations and conditional checks. It checks against the current set summary (if available), and calculates the 1RM and volume for comparison, showcasing my problem-solving skills and attention to detail.

The code is also properly documented with comments that describe its functionality, enhancing readability and understanding for other developers. This approach reflects my commitment to effective communication in code and highlights how I design functions with maintainability and collaboration in mind.

setProvider

This code sample is a React Context Provider, SetProvider, written in TypeScript, that manages the state for a set of exercise data in a workout application. It demonstrates my ability to create scalable and maintainable state management solutions using React's Context API.

The SetProvider uses both built-in React hooks like useState, useEffect, and useRef, as well as a custom hook, useAsyncStorage, showcasing my adeptness with React Hooks and the creation of custom hooks to abstract complex logic.

This code also integrates Apollo Client's useLazyQuery hook, illustrating my ability to work with GraphQL APIs. The fetchSetData function, which combines local data storage and network request, exemplifies my skill in handling asynchronous operations and demonstrates how I implement error handling in such situations.

I employ a helper function safeUpdate to safely update state only when the component is mounted, thereby handling potential errors related to state updates on unmounted components. This function also helps to reduce code repetition, showcasing my focus on clean and DRY code.

In terms of mobile development, this file illustrates my proficiency with React Native and specifically with the Async Storage module for local data storage in a mobile environment.

Overall, this piece of code displays my capabilities in modern React development, efficient state management, GraphQL usage, asynchronous operations, and the creation of maintainable and efficient code.

About

A few code snippets to show off some of the work I have done.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages