Black Sheep Code

Articles tagged "react":

How to create an imperative useConfirmationModal hook

Published:

Avoid a bunch of state hooks and handlers in your code for things like confirmation modals by encapsulating that kind of logic away in a hook.

Using cookies in React Server Components to avoid a flash the incorrect content.

Published:

We make use of NextJS's `cookies` function to access the cookies on the server side.

How to create a responsive React hook to listen for changes to cookies

Published:

Your React components may wish to listen for changes to made to cookies, whether they were made by other React code, or HTTP requests or non-React JavaScript. The CookieStore API can help.

Migrating from Remix to NextJS

Published:

NextJS appears to well and truely established. These are the steps I followed to migrate from Remix 1.9.3 to Next 14.

An overview of configuring proxy behaviour in NodeJS applications

Published:

You may wish to proxy node requests via service like mitmproxy for the purpose of analysing the requests its making or generating test data. Here's a quick reference sheet for setting this behaviour up.

How to publish a React component package, using NextJS as the compiler

Published:

Although your component library may not be making use of React Server Components and the like, it can be helpful to see how the component behaves in a NextJS context.

The problem of testability in React

Published:

It seems like there are no perfect solutions for testing in React.

Adding dark mode to a blog - how to avoid flashes of the wrong theme

Published:

I've added dark mode to this blog. Here's a few tricks I've learned.

How to configure Remix and mdx-bundler for a serverless platform - barrel files approach, Remix v1

Published:

If using Remix on a serverless platform such as Netlify we can use a build time compilation and barrel files to access frontmatter metadata.

How to get started testing a React codebase that has no tests

Published:

You've inherited a React codebase that has no tests. You're having trouble with regressions and think that tests might help, but how do you get started?

Why I've gone off React Testing Library

Published:

React Testing Library is perhaps the most popular tool for testing React applications. However its use of JSDOM under-the-hood means we often spend time dealing with browser APIs that JSDOM has not implemented.

How to configure Remix and mdx-bundler (with file system access)

Published:

How to use Remix and mdx-bundler to make use of frontmatter headers. This will allow adding publication dates, or grouping posts into series, adding tags, etc. This solution works for a non-serverless solution - it requires file system access.

I'm playing with Remix

Published:

Using Remix to generate a static blog.

Dependency injection when using redux.

Published:

An unconventional strategy to inject the behaviour of your state management in testing contexts

Different Approaches to Form Element State Management in React

Published:

Working with lists of data for form inputs such as radio buttons or checkboxes is non-trivial. I outline three approaches.

Agnostic state and service management in React

Published:

Avoid make state framework specific calls inside of your React components, and instead access them via hooks. This reduces the cognitive overhead in understanding your components, and likely allows reuse of those data fetching functions elsewhere.