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

Bug fixes #165

Merged
merged 2 commits into from
Dec 2, 2019
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
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
const __cache = new Map()

function cacheGet(key: string): any {
return __cache.get(key) || undefined
return __cache.get(key)
}

function cacheSet(key: string, value: any) {
Expand Down
12 changes: 7 additions & 5 deletions src/use-swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ function useSWR<Data = any, Error = any>(
if (args.length >= 1) {
_key = args[0]
}
if (typeof args[1] === 'function') {
if (args.length >= 2) {
fn = args[1]
} else if (typeof args[1] === 'object') {
config = args[1]
}
if (typeof args[2] === 'object') {
config = args[2]
} else {
if (typeof args[1] === 'function') {
fn = args[1]
} else if (typeof args[1] === 'object') {
config = args[1]
}
}

// we assume `key` as the identifier of the request
Expand Down