Skip to content

Instantly share code, notes, and snippets.

View ellemedit's full-sized avatar
🏠
Working from home

Marshall Han ellemedit

🏠
Working from home
  • Seoul
  • 01:58 (UTC +09:00)
View GitHub Profile
@ellemedit
ellemedit / package.json
Last active July 9, 2024 04:02
`~/` alias like subpath import config in Next.js
{
"imports": {
"#styled-system/*": "./src/styled-system/*/index.js", // remove if you don't use pandacss
"#*": {
"react-server": [
"./src/*.ts",
"./src/*.tsx",
"./src/*.server.ts",
"./src/*.server.tsx"
],
@ellemedit
ellemedit / README.md
Created June 21, 2024 01:27
React Form Action + Validation + Focus + State patterns

Usage

function LoginForm() {
  const [state, dispatch] = useActionState(loginFormAction, {});
  const [_isPending, formAction] = useFormAction(async (formData, form) => {
    dispatch({ type: "RESET" });
    const errors = validateForm(formData);
    if (errors != null) {
      dispatch({ type: "SET_INVALID_INPUTS", form, errors });
@ellemedit
ellemedit / prettier.config.mjs
Last active June 20, 2024 12:59
favorite prettier config
/**
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
const config = {
trailingComma: "all",
printWidth: 120,
tabWidth: 2,
arrowParens: "always",
semi: false,
@ellemedit
ellemedit / package.json
Created June 20, 2024 12:48
Subpath import package.json configuration example
{
// ...,
"imports": {
"#styled-system/*": "./src/styled-system/*/index.js",
"#*": [
"./src/*.ts",
"./src/*.tsx",
"./src/*"
]
}
@ellemedit
ellemedit / README.md
Created June 19, 2024 06:45
A ReactDOM hook that allows you to reset form optionally after submitting

Example:

function Form() {
  const [isPending, onSubmit] = useFormActionHandler((formData, reset) => {
    if (formData.get('condition') === 'X') {
      reset();
    }
    // ...
 });
@ellemedit
ellemedit / .gitconfig
Created March 6, 2024 02:05
my git config
# This is Git's per-user configuration file.
[user]
name = BaHwan Han
email = [email protected]
[push]
default = current
[core]
pager = delta
@ellemedit
ellemedit / taste.md
Last active March 1, 2024 01:00
My Taste Next.js

editorconfig

# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
@ellemedit
ellemedit / next.config.mjs
Created October 26, 2023 04:15
next.js server component svg fix
const config = {
// ...
webpack(config) {
// prevent ehters.js node deps import warnings
config.externals.push({
bufferutil: "bufferutil",
"utf-8-validate": "utf-8-validate",
});
@ellemedit
ellemedit / README.md
Last active July 29, 2023 05:02
React@canary async action bug monkey patch
@ellemedit
ellemedit / OperationFetcherBuilder.ts
Last active May 22, 2023 08:34
나만의 OAS Generator + Query hooks
import {
ClientBuilder,
ClientDependenciesBuilder,
ClientFooterBuilder,
ClientGeneratorsBuilder,
ClientHeaderBuilder,
ClientTitleBuilder,
generateFormDataAndUrlEncodedFunction,
generateMutatorConfig,
generateMutatorRequestOptions,