Skip to content

Instantly share code, notes, and snippets.

TypeError: Cannot read property 'status' of undefined.

Christian Petersen fnky

TypeError: Cannot read property 'status' of undefined.
View GitHub Profile
fnky / use-toggle.ts
Created May 13, 2022
Simple toggle hook using useReducer w/ types for reducer with optional action.
View use-toggle.ts
import React from "react";
type ReducerWithOptionalAction<S> = (prevState: S, action?: S) => S;
type ReducerStateWithOptionalAction<S> = React.ReducerState<ReducerWithOptionalAction<S>>;
type DispatchWithOptionalAction<S> = React.Dispatch<S> & React.DispatchWithoutAction;
type ReducerValueWithOptionalAction<S> = [
fnky / login.tsx
Last active Sep 11, 2022
Remix Form validation with zod
View login.tsx
import { json, ActionFunction, useActionData, Form } from "remix";
import { z } from "zod";
// This type infer errors from a ZodType, as produced by `flatten()` of a parsed schema.
type inferSafeParseErrors<T extends z.ZodType<any, any, any>, U = string> = {
formErrors: U[];
fieldErrors: {
[P in keyof z.infer<T>]?: U[];
fnky / Cargo.toml
Created Sep 22, 2021
Rule110 in Rust
View Cargo.toml
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
fnky / BetterFixedLazyExample.jsx
Last active Nov 29, 2019
Lazy conditionals and refs
View BetterFixedLazyExample.jsx
function BetterFixedLazyExample({ lazyValue }) {
// Initialize with null value.
const myRef = useRef(null);
useLayoutEffect(() => {
console.log(myRef.current); // => HTMLDivElement DOM node
}, []);
// Make sure the ref setter is not blocked by conditionals.
return (
fnky / history-with-outer.jsx
Last active Nov 27, 2019
History provider with useState / useRef
View history-with-outer.jsx
import React from 'react';
import { createBrowserHistory } from 'history';
export const historyContext = React.createContext(null);
const HistoryContextProvider = historyContext.Provider;
// This is initialized at the time the file/module is imported, and not on component mount.
const history = createBrowserHistory();
export function History(props) {
fnky /
Created Oct 18, 2019
Cheap-ish fonts

Cheap-ish fonts

A list of cheap-ish fonts, that doesn't put a dent in my wallet.

fnky /
Last active May 7, 2022
Awesome Variable Fonts

Awesome Variable Fonts

A list of open source and free* variable fonts.

* Some fonts may require a license to be used for commerical use.

Open Source

fnky /
Created Oct 16, 2019
Binary serialization frameworks, libraries and tools
fnky / stripe-keys-and-ids.tsv
Last active Oct 3, 2022
Stripe keys and IDs
View stripe-keys-and-ids.tsv
Prefix Description Notes
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
aliacc_ Alipay Account ID Identifier for an Alipay account.
ba_ Bank Account ID Identifier for a Bank Account object.
btok_ Bank Token ID Identifier for a Bank Token object.
card_ Card ID Identifier for a Card object.
cbtxn_ Customer Balance Transaction ID Identifier for a Customer Balance Transaction object.
ch_ Charge ID Identifier for a Charge object.
cn_ Credit Note ID Identifier for a Credit Note object.
View query-order.graphql
# Query order pattern from GitHub GraphQL API
# Can be used in conjunction with Relay pagination.
Possible directions in which to order a list of items when provided an `orderBy` argument.
enum OrderDirection {
Specifies an ascending order for a given `orderBy` argument.