Skip to content

Commit

Permalink
remove the 'use client' directive and add client-only to useSWR entry. (
Browse files Browse the repository at this point in the history
#2705)

Co-authored-by: Jiachi Liu <[email protected]>
  • Loading branch information
promer94 and huozhi authored Jul 6, 2023
1 parent f0d80d3 commit 2efed28
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"clean": "rimraf dist"
},
"peerDependencies": {
"client-only": "*",
"swr": "*",
"react": "*",
"use-sync-external-store": "*"
Expand Down
1 change: 1 addition & 0 deletions core/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'client-only'
2 changes: 1 addition & 1 deletion core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use client'
import 'client-only'

// useSWR
import useSWR from './use-swr'
Expand Down
2 changes: 0 additions & 2 deletions immutable/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client'

import type { Middleware } from 'swr'
import useSWR from 'swr'
import { withMiddleware } from 'swr/_internal'
Expand Down
2 changes: 0 additions & 2 deletions infinite/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client'

// We have to several type castings here because `useSWRInfinite` is a special
// hook where `key` and return type are not like the normal `useSWR` types.

Expand Down
2 changes: 0 additions & 2 deletions mutation/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client'

import { useCallback, useRef } from 'react'
import useSWR, { useSWRConfig } from 'swr'
import type { Middleware, Key } from 'swr/_internal'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
"trailingComma": "none"
},
"dependencies": {
"client-only": "^0.0.1",
"use-sync-external-store": "^1.2.0"
}
}
4 changes: 3 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions subscription/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client'

import type { Key, SWRHook, Middleware, SWRConfiguration, SWRConfig } from 'swr'
import type {
SWRSubscriptionOptions,
Expand Down

0 comments on commit 2efed28

Please sign in to comment.