Skip to content

Commit

Permalink
Merge branch 'main' into fix/keyed-mutator-type-error
Browse files Browse the repository at this point in the history
  • Loading branch information
Key5n authored Apr 8, 2024
2 parents cc1ac3e + 6da84a3 commit 4882ab3
Show file tree
Hide file tree
Showing 66 changed files with 1,682 additions and 1,002 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ jobs:
run: |
pnpm clean
pnpm build
pnpm run-all-checks
pnpm test
pnpm test:build
28 changes: 28 additions & 0 deletions .github/workflows/test-legacy-react.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test React 17

on:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install
uses: ./.github/workflows/install

- name: Test
env:
TEST_REACT_LEGACY: 1
run: |
pnpm clean
pnpm build
pnpm test
pnpm test:build
2 changes: 1 addition & 1 deletion _internal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"main": "../dist/_internal/index.js",
"module": "../dist/_internal/index.esm.js",
"module": "../dist/_internal/index.mjs",
"types": "../dist/_internal/index.d.ts",
"private": true
}
17 changes: 17 additions & 0 deletions e2e/site/app/suspense-fallback/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { SWRConfig } from 'swr'

function createPromiseData(data: any, timeout: number) {
return new Promise(resolve => {
setTimeout(() => {
resolve(data)
}, timeout)
})
}

export default function Layout({ children }: { children: React.ReactNode }) {
const fallback = {
'/api/promise': createPromiseData({ value: 'async promise' }, 2000)
}

return <SWRConfig value={{ fallback }}>{children}</SWRConfig>
}
9 changes: 9 additions & 0 deletions e2e/site/app/suspense-fallback/promise/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client'

import useSWR from 'swr'

export default function Page() {
const { data, isLoading } = useSWR('/api/promise')

return <div>{isLoading ? 'loading...' : data?.value}</div>
}
6 changes: 1 addition & 5 deletions e2e/site/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverActions: true,
},
}
const nextConfig = {}

module.exports = nextConfig
2 changes: 1 addition & 1 deletion e2e/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@types/node": "^20.2.5",
"@types/react": "^18.2.8",
"@types/react-dom": "18.2.4",
"next": "^13.4.4",
"next": "^14.1.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "5.1.3",
Expand Down
11 changes: 11 additions & 0 deletions e2e/test/suspense-fallback.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test.describe('suspense fallback', () => {
test('should wait for promise fallback value to be resolved', async ({
page
}) => {
await page.goto('./suspense-fallback/promise', { waitUntil: 'commit' })
await expect(page.getByText('async promise')).toBeVisible()
})
})
1 change: 0 additions & 1 deletion env.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions examples/api-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/autocomplete-suggestions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"@reach/combobox": "0.16.1",
"lodash.debounce": "4.0.8",
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/axios-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"axios": "0.23.0",
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/axios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"axios": "0.27.2",
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/focus-revalidate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/global-fetcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/infinite-scroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/infinite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/local-state-sharing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"next": "latest",
"swr": "latest"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/optimistic-ui-immer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"immer": "9.0.5",
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/optimistic-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/prefetch-preload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/refetch-interval/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/server-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/storage-tab-sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "latest",
"react-dom": "latest",
"swr": "latest"
},
"scripts": {
Expand Down
Binary file added examples/suspense/app/favicon.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions examples/suspense/app/layout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function RootLayout({
children
}) {
return (
<html lang="en">
<body style={{ textAlign: 'center' }}>{children}</body>
</html>
)
}
4 changes: 4 additions & 0 deletions examples/suspense/app/rsc/[user]/[repo]/error.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use client'
export default function ErrorPage() {
return <div>Error happen</div>;
}
3 changes: 3 additions & 0 deletions examples/suspense/app/rsc/[user]/[repo]/loading.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Loading() {
return <div>Loading...</div>;
}
23 changes: 23 additions & 0 deletions examples/suspense/app/rsc/[user]/[repo]/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Repo from './repo'
import fetcher from '../../../../libs/fetch'
import Link from 'next/link'
import { Suspense } from 'react'
const Page = ({ params }) => {
const { user, repo } = params
const id = `${user}/${repo}`
const serverData = fetcher('http://localhost:3000/api/data?id=' + id)
return (
<div>
<div>Repo: {id}</div>
<Suspense fallback={<div>Loading stats</div>}>
<Repo serverData={serverData} id={id} />
</Suspense>
<br />
<br />
<Link href="/rsc">Back</Link>
</div>
)
}


export default Page
21 changes: 21 additions & 0 deletions examples/suspense/app/rsc/[user]/[repo]/repo.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client'
import fetcher from '../../../../libs/fetch'
import useSWR from 'swr'

const Repo = ({ id, serverData }) => {
const { data } = useSWR('/api/data?id=' + id, fetcher, { suspense: true, fallbackData: serverData })
return (
<>
{data ? (
<div>
<p>forks: {data.forks_count}</p>
<p>stars: {data.stargazers_count}</p>
<p>watchers: {data.watchers}</p>
</div>
) : null}

</>
)
}

export default Repo
3 changes: 3 additions & 0 deletions examples/suspense/app/rsc/loading.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Loading() {
return <div>Loading...</div>;
}
8 changes: 8 additions & 0 deletions examples/suspense/app/rsc/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import fetcher from '../../libs/fetch'
import Repos from './repos'
const Page = () => {
const serverData = fetcher('http://localhost:3000/api/data')
return <Repos serverData={serverData} />
}

export default Page
Loading

0 comments on commit 4882ab3

Please sign in to comment.