Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
ryanflorence / mutations.md
Created April 23, 2021 19:33
Created from Remix Form!

hello hello

@ryanflorence
ryanflorence / blah.md
Created April 23, 2021 19:32
Created from Remix Form!

hello hello

import type {
ActionFunction,
LinksFunction,
LoaderFunction,
MetaFunction
} from "@remix-run/react";
import {
Meta,
Links,
Scripts,
const path = require("path");
const express = require("express");
const compression = require("compression");
const morgan = require("morgan");
const { createRequestHandler } = require("@remix-run/express");
////////////////////////////////////////////////////////////////////////////////
let app = express();
app.use(compression());
enum State {
Idle,
LoadingJwt,
Success,
Error,
}
type Data = { error?: string; jwt?: string };
function Comp() {
import React from "react";
import { IconCopy } from "./icons";
export default function CopyButton({ value }) {
let [copied, setCopied] = React.useState(false);
React.useEffect(() => {
if (copied) {
let id = setTimeout(() => {
setCopied(false);

Calling Loaders/Actions Outside of Navigation

Some might call them "API routes".

Use cases:

  • Combobox suggestions in a form.
    • This is not semantically navigation
  • Single action buttons that don't quite feel like navigation
  • like clicking a bunch of delete buttons really fast in a list

Route Module Pending Component Export

There are two primary approaches to page transitions (ignoring suspense's ditched attempt at a third)

  1. Indefinitely wait on the old screen
  2. Transition immediately to spinners/skeleton

Right now Remix has picked #1, but with a new export to a route module, we could support both.

Today, if you have this, Remix will wait for all data to load before displaying the page

<LoadingButton
ariaErrorAlert={"There was an error creating your account"}
ariaLoadingAlert={
authState === AuthState.CreatingUser
? "Registering account, please wait..."
: authState === AuthState.FulfillingPurchase
? "Generating license, please wait..."
: "Loading..."
}
ariaSuccessAlert="Account created! Redirecting."
const fsp = require("fs").promises;
const path = require("path");
const { execSync } = require("child_process");
const chalk = require("chalk");
const Confirm = require("prompt-confirm");
const jsonfile = require("jsonfile");
const semver = require("semver");
const packagesDir = path.resolve(__dirname, "../packages");