Posts categorized as code
Concatenate multiple optional items with separators
π2020-09-22π±code
Concatenating strings is a pretty straight forward task in JavaScript and with the introduction of template literals with string interpolation things got even simpler. Let's say that we want to concat a couple of inputs of a form that isβ¦
Update state with useReducer synchronously
π2020-01-24π±code
Hooks in Reacts are wonderful to work with and managing local state is one of the most common ones. For more complex states the useState() hook could be changed to a useReducer() instead. A problem we might encounter is that state isn'tβ¦
Partial types in TypeScript
π2019-11-21π±code
TypeScript is great for many reasons and when getting past the first few steps it really makes developing a joy. With that said there may come a time when objects keep growing in size and maybe not all properties will exist all the timeβ¦
Conditions in CSS with the :not pseudo class
π2019-08-05π±code
When writing CSS we sometimes want some more logic to our styling. For example a navigation with multiple elements in a horizontal layout probably needs some space between the elements. A padding-right could do it but we don't wantβ¦
Put GraphQL fragments in their own files in Gatsby
π2019-07-15π±code
Gatsby uses GraphQL under the hood for managing data and it does this really well. It usually doesn't take long before the queries grow big and some duplicated code will occur. This is where fragments come in handy. A way to break outβ¦