Skip to content

Commit e54376d

Browse files
authored
Merge pull request #183 from croutonn/fix-useSWRInfinite-import
Fix import `useSWRInfinite` statement
2 parents 3e3c7f8 + 8892af4 commit e54376d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/visitor.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ export class SWRVisitor extends ClientSideBaseVisitor<
124124
this._additionalImports.push(
125125
`import type { SWRInfiniteConfiguration } from 'swr/infinite';`
126126
)
127+
this._additionalImports.push(`import useSWR from 'swr';`)
127128
this._additionalImports.push(
128-
`import useSWR, { useSWRInfinite } from 'swr';`
129+
`import useSWRInfinite from 'swr/infinite';`
129130
)
130131
} else {
131132
this._additionalImports.push(
@@ -135,10 +136,10 @@ export class SWRVisitor extends ClientSideBaseVisitor<
135136
}
136137
} else if (this._enabledInfinite) {
137138
this._additionalImports.push(
138-
`import useSWR, { useSWRInfinite, SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
139+
`import useSWR, { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
139140
)
140141
this._additionalImports.push(
141-
`import { SWRInfiniteConfiguration } from 'swr/infinite';`
142+
`import useSWRInfinite, { SWRInfiniteConfiguration } from 'swr/infinite';`
142143
)
143144
} else {
144145
this._additionalImports.push(

tests/swr.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ async function test() {
234234
const usage = basicUsage
235235
const output = await validate(content, config, docs, schema, usage)
236236
expect(content.prepend).toContain(
237-
`import useSWR, { useSWRInfinite, SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
237+
`import useSWR, { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
238238
)
239239
expect(content.prepend).toContain(
240-
`import { SWRInfiniteConfiguration } from 'swr/infinite';`
240+
`import useSWRInfinite, { SWRInfiniteConfiguration } from 'swr/infinite';`
241241
)
242242
expect(output).toContain(readOutput('infinite'))
243243
})

0 commit comments

Comments
 (0)