Skip to content

Instantly share code, notes, and snippets.

View isimmons's full-sized avatar
😁
Having fun learning to code

Ian isimmons

😁
Having fun learning to code
View GitHub Profile
@mjackson
mjackson / redirects-in-react-router-v6.md
Last active July 17, 2025 02:50
Notes on handling redirects in React Router v6, including a detailed explanation of how this improves on what we used to do in v4/5

Redirects in React Router v6

An important part of "routing" is handling redirects. Redirects usually happen when you want to preserve an old link and send all the traffic bound for that destination to some new URL so you don't end up with broken links.

The way we recommend handling redirects has changed in React Router v6. This document explains why.

Background

In React Router v4/5 (they have the same API, you can read about why we had to bump the major version here) we had a <Redirect> component that you could use to tell the router when to automatically redirect to another URL. You might have used it like this:

@jossmac
jossmac / asyncQuerySelector.js
Created May 31, 2018 05:47
An async querySelector equivalent
import "babel-polyfill";
const asyncQuerySelector = async (node, query) => {
try {
return await (query ? node.querySelector(query) : node);
} catch (error) {
console.error(`Cannot find ${query ? `${query} in`: ''} ${node}.`, error);
return null;
}
};
@magnetikonline
magnetikonline / README.md
Last active July 10, 2025 04:51
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set, value is returned.

Combine with a : no-op to discard/ignore return value.
${variable="value"}
: ${variable="value"}