Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with Remix v2_normalizeFormMethod #187

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/remix-1-15/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
};
6 changes: 6 additions & 0 deletions apps/remix-1-15/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules

/.cache
/build
/public/build
.env
53 changes: 53 additions & 0 deletions apps/remix-1-15/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Welcome to Remix!

- [Remix Docs](https://remix.run/docs)

## Development

From your terminal:

```sh
npm run dev
```

This starts your app in development mode, rebuilding assets on file changes.

## Deployment

First, build your app for production:

```sh
npm run build
```

Then run the app in production mode:

```sh
npm start
```

Now you'll need to pick a host to deploy it to.

### DIY

If you're familiar with deploying node applications, the built-in Remix app server is production-ready.

Make sure to deploy the output of `remix build`

- `build/`
- `public/build/`

### Using a Template

When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server.

```sh
cd ..
# create a new project, and pick a pre-configured host
npx create-remix@latest
cd my-new-remix-app
# remove the new project's app (not the old one!)
rm -rf app
# copy your app over
cp -R ../my-old-remix-app/app app
```
6 changes: 6 additions & 0 deletions apps/remix-1-15/app/formAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { json, redirect } from '@remix-run/node'
import { createFormAction } from 'remix-forms'

const formAction = createFormAction({ redirect, json })

export { formAction }
27 changes: 27 additions & 0 deletions apps/remix-1-15/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";

export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}
23 changes: 23 additions & 0 deletions apps/remix-1-15/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { makeDomainFunction } from 'domain-functions'
import type { ActionFunctionArgs } from 'react-router-dom'
import { z } from 'zod'
import { formAction } from '../formAction'
import { Form } from '../ui/form'

const schema = z.object({
firstName: z.string().min(1),
email: z.string().min(1).email(),
})

const mutation = makeDomainFunction(schema)(async (values) => values)

export function action({ request }: ActionFunctionArgs) {
return formAction({
request,
schema,
mutation,
successPath: '/success',
})
}

export default () => <Form schema={schema} />
1 change: 1 addition & 0 deletions apps/remix-1-15/app/routes/success.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => <h1>Success!</h1>
16 changes: 16 additions & 0 deletions apps/remix-1-15/app/ui/form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createForm } from 'remix-forms'
import {
Form as RemixForm,
useActionData,
useSubmit,
useNavigation,
} from '@remix-run/react'

const Form = createForm({
component: RemixForm,
useNavigation,
useSubmit,
useActionData,
})

export { Form }
34 changes: 34 additions & 0 deletions apps/remix-1-15/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "remix-forms-remix-1-15",
"private": true,
"sideEffects": false,
"scripts": {
"build": "remix build",
"dev": "PORT=3002 remix dev",
"start": "remix-serve build",
"tsc": "tsc"
},
"dependencies": {
"@remix-run/node": "1.15.0",
"@remix-run/react": "1.15.0",
"@remix-run/serve": "1.15.0",
"domain-functions": "^1.0.0",
"isbot": "^3.6.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remix-forms": "*",
"zod": "^3.12.0"
},
"devDependencies": {
"@remix-run/dev": "1.15.0",
"@remix-run/eslint-config": "1.15.0",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"eslint": "^8.27.0",
"eslint-config-custom": "*",
"typescript": "~4.5.5"
},
"engines": {
"node": ">=14"
}
}
Binary file added apps/remix-1-15/public/favicon.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions apps/remix-1-15/remix.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
ignoredRouteFiles: ["**/.*"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// serverBuildPath: "build/index.js",
// publicPath: "/build/",
future: {
v2_errorBoundary: true,
v2_meta: true,
v2_normalizeFormMethod: true,
v2_routeConvention: true,
},
};
2 changes: 2 additions & 0 deletions apps/remix-1-15/remix.env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node" />
32 changes: 32 additions & 0 deletions apps/remix-1-15/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"include": [
"remix.env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"compilerOptions": {
"lib": [
"DOM",
"DOM.Iterable",
"ES2019"
],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./app/*"
]
},
"skipLibCheck": true,
// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}
Loading