Skip to content

Instantly share code, notes, and snippets.

View fnky's full-sized avatar
⚠️
TypeError: Cannot read property 'status' of undefined.

Christian Petersen fnky

⚠️
TypeError: Cannot read property 'status' of undefined.
View GitHub Profile
@fnky
fnky / login.tsx
Last active December 15, 2023 19:56
Remix Form validation with zod
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
fnky / use-toggle.ts
Created May 13, 2022 12:29
Simple toggle hook using useReducer w/ types for reducer with optional action.
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> = [
ReducerStateWithOptionalAction<S>,
React.DispatchWithOptionalAction<S>,
];
@fnky
fnky / react-web-resources.md
Last active November 24, 2023 15:04
Web/React Resources (Last updated Nov 3, 2022)
@fnky
fnky / news.ycombinator.com.css
Last active January 13, 2023 23:32
Stylus Dark theme for Hacker News
:root {
--color-scale-black: hsl(0, 0%, 3.5%);
--color-scale-white: #ffffff;
--color-scale-gray-1: hsl(0, 0%, 8.5%);
--color-scale-gray-2: hsl(0, 0%, 11.0%);
--color-scale-gray-3: hsl(0, 0%, 13.6%);
--color-scale-gray-4: hsl(0, 0%, 15.8%);
--color-scale-gray-5: hsl(0, 0%, 17.9%);
--color-scale-gray-6: hsl(0, 0%, 20.5%);
--color-scale-gray-7: hsl(0, 0%, 24.3%);