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

dispatch's payload type is actionType and run lint #772

Merged
merged 2 commits into from
Nov 15, 2020
Merged
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions src/use-swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import {
} from './types'

// @ts-ignore
const IS_SERVER = typeof window === 'undefined' || !!(typeof Deno !== 'undefined' && Deno && Deno.version && Deno.version.deno)
const IS_SERVER =
typeof window === 'undefined' ||
!!(typeof Deno !== 'undefined' && Deno && Deno.version && Deno.version.deno)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the tests pass, you need to move that // @ts-ignore (line 28) here.


// polyfill for requestAnimationFrame
const rAF = IS_SERVER
Expand Down Expand Up @@ -301,7 +303,7 @@ function useSWR<Data = any, Error = any>(
useDebugValue(stateRef.current.data)

const rerender = useState(null)[1]
let dispatch = useCallback(payload => {
let dispatch = useCallback((payload: actionType<Data, Error>) => {
let shouldUpdateState = false
for (let k in payload) {
if (stateRef.current[k] === payload[k]) {
Expand Down