Skip to content

Commit

Permalink
renamed trigger function use*Api hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed May 23, 2024
1 parent 0310dba commit 8e87fc5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/next-drupal/src/hooks/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function useApi(
loading: false,
})

const getData = useCallback(
const api = useCallback(
async (opts?: RequestInit) => {
setState((state) => ({ ...state, loaded: false, loading: true }))

Expand Down Expand Up @@ -82,12 +82,12 @@ export function useApi(
[path],
)

const value = useMemo(() => ({ ...state, getData }), [state, getData])
const value = useMemo(() => ({ ...state, api }), [state, api])

useEffect(() => {
if (opts?.manualTrigger) return
getData(opts)
}, [getData, opts, deps])
api(opts)
}, [api, opts, deps])

return value
}
8 changes: 4 additions & 4 deletions packages/next-drupal/src/hooks/useDrupalApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function useDrupalApi(
loading: false,
})

const getData = useCallback(
const api = useCallback(
async (opts?: FetchOptions) => {
if (!drupal) return

Expand Down Expand Up @@ -66,12 +66,12 @@ export function useDrupalApi(
[path],
)

const value = useMemo(() => ({ ...state, getData }), [state, getData])
const value = useMemo(() => ({ ...state, api }), [state, api])

useEffect(() => {
if (opts?.manualTrigger) return
getData(opts)
}, [getData, opts, deps])
api(opts)
}, [api, opts, deps])

return value
}
8 changes: 4 additions & 4 deletions packages/next-drupal/src/hooks/useDrupalViewApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function useDrupalViewApi(
loading: false,
})

const getData = useCallback(
const api = useCallback(
async (params?: Params, opts?: Options) => {
if (!drupal) return

Expand Down Expand Up @@ -68,12 +68,12 @@ export function useDrupalViewApi(
[viewId],
)

const value = useMemo(() => ({ ...state, getData }), [state, getData])
const value = useMemo(() => ({ ...state, api }), [state, api])

useEffect(() => {
if (opts?.manualTrigger) return
getData(params, opts)
}, [getData, params, opts, deps])
api(params, opts)
}, [api, params, opts, deps])

return value
}

0 comments on commit 8e87fc5

Please sign in to comment.