Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.

Commit 8163e80

Browse files
committed
feat: support name conventions of next remix releases
1 parent 82f9d08 commit 8163e80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+83
-67
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
>For more information, please refer to the React Router [documentation](https://reactrouter.com/en/main). Note that it follows the Remix file convention.
88
9+
>**Important**
10+
although react-router use names `loader`, `action`, `Component` these parts should exported from file as `clientLoader`, `clientAction`, `default`, see example below. use these name for future react-router releases.
11+
912
## Install
1013

1114
```bash
@@ -117,12 +120,14 @@ export const caseSensitive = false
117120

118121
export const id = 'main-page'
119122

120-
export async function loader() {}
123+
// every `loader` should exported by name `clientLoader` from v2
124+
export async function clientLoader() {}
121125

122-
export async function action() {}
126+
// every `action` should exported by name `clientAction` from v2
127+
export async function clientAction() {}
123128

124-
// every component should exported without default with name `Component`
125-
export function Component() {
129+
// every component should exported as `default` no matter what is the name from v2
130+
export default function Component() {
126131
return <h1>Hello Remix Router!</h1>
127132
}
128133

playground/app/root.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import React from 'react'
44
import { Outlet } from 'react-router-dom'
55

6-
export function Component() {
6+
7+
8+
export default function Component() {
79
return (
810
<>
911
<h1>test for first page</h1>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
22

3-
export function Component() {
3+
export default function Component() {
44
return <h1>dashboard</h1>
55
}

playground/app/routes/_auth.lazy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React from 'react'
44
import { Outlet } from 'react-router-dom'
55

6-
export function Component() {
6+
export default function Component() {
77
return (
88
<>
99
<h1>hidden auth layout</h1>

playground/app/routes/_auth.login.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react'
22
import { useLoaderData } from 'react-router-dom'
33

4-
export async function loader() {
4+
export async function clientLoader() {
55
// sleep 2 seconds then return data
66
await new Promise(resolve => setTimeout(resolve, 2000))
77
return ['Note 1', 'Note 2', 'Note 3']
88
}
99

10-
export function Component() {
10+
export default function Component() {
1111
const notes = useLoaderData() as string[]
1212

1313
return (

playground/app/routes/_index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useState } from 'react'
22
import { useLoaderData } from 'react-router-dom'
33

4-
export async function loader() {
4+
export async function clientLoader() {
55
return 'Vite + React'
66
}
77

8-
export function Component() {
8+
export default function Component() {
99
const [count, setCount] = useState(0)
1010
const data = useLoaderData() as string
1111

playground/app/routes/auth.$.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
22

3-
export function Component() {
3+
export default function Component() {
44
return <h1>Splat Route</h1>
55
}

playground/app/routes/auth.$test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
22

3-
export function Component() {
3+
export default function Component() {
44
return <h1>Dynamic Route</h1>
55
}

playground/app/routes/auth.deploy.lazy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { Outlet } from 'react-router-dom'
33

4-
export function Component() {
4+
export default function Component() {
55
return (
66
<>
77
<h1>deploy</h1>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
22

3-
export function Component() {
3+
export default function Component() {
44
return <h1>deploy test</h1>
55
}

0 commit comments

Comments
 (0)