< Blog

Snippets

Short solutions to discrete problems.

There is no need to import classnames from NPM - instead use this simple function.

#Javascript#CSS

Sometimes when you are testing, or playing around, you just want to simulate some delay. Here's a simple way to do just that.

#Javascript

This snippet shows how to create a custom NavLink component in Next.js 13 that extends the built-in Link component to add CSS classNames when the href attribute matches the current URL.

#Javascript

Sometimes you just want to add a Tweet to a post. Should be simple, right? With .mdx you have some different choices that are worth considering.

#Javascript#React Component

I have documented some React hooks I find useful but there are many, many hooks out there. Here are some great React Hooks resources. Cheers!

#Javascript#React Hook

Implementing Google Tag Manager in Nextjs.

#Javascript

Debouncing is a strategy that lets us improve performance by waiting until a certain amount of time has passed before triggering an event.

#Javascript

Animated slide in pane component with Framer Motion

#Javascript

How to get the last segment of a path or URL using JavaScript.

#Javascript

Compile and bundler MDX files with mdx-bundler

#Javascript

Recursive timeout function that can be used for timed events.

#React Hook

When dealing with a server-side rendered application it can be useful to know when you are rendering on the client.

#React Hook

useMediaQuery is a react hook that makes testing for media query matches in your code easier and simpler.

#React Hook

Some people do not prefer animations, and for some motion can be harmful. The prefers-reduced-motion CSS media query allows us to disable animations.

#React Hook

Using Google Analytics API to get page data.

#Javascript

The Intersection Observer API allows you to configure a callback that is called whenever an element intersects either the device viewport.

#React Hook

Adding SEO using a wrapper container

#React Hook