-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- reference react-hook-form/react-hook-form#10391
- Loading branch information
Showing
28 changed files
with
1,649 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,52 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"plugin:react/recommended", | ||
"plugin:react-hooks/recommended", | ||
"plugin:tailwindcss/recommended" | ||
], | ||
"plugins": [ | ||
"simple-import-sort", | ||
"unused-imports", | ||
"tailwindcss" | ||
], | ||
"settings": { | ||
"tailwindcss": { | ||
"callees": ["cn"], | ||
"config": "tailwind.config.js" | ||
}, | ||
"next": { | ||
"rootDir": ["./src/"] | ||
} | ||
}, | ||
"rules": { | ||
// Code style | ||
"indent": ["error", 2], | ||
"quotes": ["error", "double"], | ||
"semi": ["error", "always"], | ||
"comma-dangle": ["error", { | ||
"arrays": "always-multiline", | ||
"objects": "always-multiline", | ||
"imports": "never", | ||
"exports": "never", | ||
"functions": "never" | ||
}], | ||
"comma-spacing": ["error", { "before": false, "after": true }], | ||
"no-console": "warn", | ||
"tailwindcss/no-custom-classname": "off", | ||
|
||
// import / export | ||
"simple-import-sort/imports": "error", | ||
"simple-import-sort/exports": "error", | ||
"unused-imports/no-unused-imports-ts": ["error"], | ||
|
||
// React | ||
"react/react-in-jsx-scope": 0, | ||
"react/jsx-first-prop-new-line": "error", | ||
"react/self-closing-comp": ["error", { | ||
"component": true, | ||
"html": true | ||
}], | ||
"react/no-unknown-property": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// tailwind @import | ||
"css.lint.unknownAtRules": "ignore", | ||
// eslint | ||
"eslint.format.enable": true, | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint", | ||
// use ts path alias | ||
"typescript.preferences.importModuleSpecifier": "non-relative", | ||
// tailwindcss + cva | ||
"tailwindCSS.experimental.classRegex": [ | ||
[ | ||
"cva\\(([^)]*)\\)", | ||
"[\"'`]([^\"'`]*).*?[\"'`]" | ||
], | ||
[ | ||
"cx\\(([^)]*)\\)", | ||
"(?:'|\"|`)([^']*)(?:'|\"|`)" | ||
] | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,26 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
# React Hook Form with Server Actions | ||
|
||
## Getting Started | ||
I created custom hooks to handle server actions with React Hook Form. | ||
It's declarative way to handle form validation and submission, success and error cases. | ||
|
||
First, run the development server: | ||
1. keep **progressive enhancement** working | ||
2. handle actions and form state via `useFormState` and `useFormStatus`. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
npm install global pnpm | ||
pnpm install | ||
pnpm dev | ||
# or | ||
bun dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
## Main Source Code | ||
|
||
## Deploy on Vercel | ||
- [useFormAction](./src/hooks/useFormAction.js) | ||
- [action.d.ts](./src/types/action.d.ts) | ||
- If you want to add your own handler, check this file. | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
## Sample | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. | ||
- [client side form](./src/app/client-side-form.tsx) | ||
- [actions](./src/actions.ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": true, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.ts", | ||
"css": "src/app/globals.css", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.