Skip to content

Commit

Permalink
fix: linter warnings (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats authored Mar 15, 2023
1 parent 41db186 commit 4222c9c
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions packages/react/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,38 +68,6 @@ const Card = props => {
[isLazyEnabled, hasIntersected]
)

const toFetchData = useCallback(() => {
if (canFetchData) {
setLoading(true)

const fetch = fetchData
? fetchFromApi(apiUrl, apiUrlProps)
: Promise.resolve({})

fetch
.then(({ data }) => mergeData(data))
.catch(error => {
setLoading(false)
setIsError(true)
console.error(`
┌───────────────┐
│ Microlink SDK │
└───────────────┘
${error.description}
${JSON.stringify(error.data)}
id ${error.headers['x-request-id']}
uri ${error.url}
code ${error.code} (${error.statusCode})
microlink.io/${error.code.toLowerCase()}
`)
})
}
}, [apiUrl, canFetchData, setData, apiUrlProps.headers['x-api-key'], url])

const mergeData = useCallback(
fetchedData => {
const payload = isFunction(setData)
Expand Down Expand Up @@ -153,10 +121,42 @@ microlink.io/${error.code.toLowerCase()}

setLoading(false)
},
[mediaProps, setData]
[updateState, mediaProps, setData]
)

useEffect(toFetchData, [url, setData, hasIntersected])
const toFetchData = useCallback(() => {
if (canFetchData) {
setLoading(true)

const fetch = fetchData
? fetchFromApi(apiUrl, apiUrlProps)
: Promise.resolve({})

fetch
.then(({ data }) => mergeData(data))
.catch(error => {
setLoading(false)
setIsError(true)
console.error(`
┌───────────────┐
│ Microlink SDK │
└───────────────┘
${error.description}
${JSON.stringify(error.data)}
id ${error.headers['x-request-id']}
uri ${error.url}
code ${error.code} (${error.statusCode})
microlink.io/${error.code.toLowerCase()}
`)
})
}
}, [apiUrlProps, fetchData, apiUrl, mergeData, canFetchData])

useEffect(toFetchData, [toFetchData, url, setData, hasIntersected])

const isLoading = isLoadingUndefined ? loadingState : loading

Expand Down

4 comments on commit 4222c9c

@vercel
Copy link

@vercel vercel bot commented on 4222c9c Mar 15, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

sdk-react – ./packages/react

sdk-react-microlink.vercel.app
sdk-react.microlink.io
sdk-react.vercel.app
sdk-react-git-master-microlink.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4222c9c Mar 15, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 4222c9c Mar 15, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

sdk-hover-vanilla – ./packages/hover-vanilla

sdk-hover-vanilla-microlink.vercel.app
sdk-hover-vanilla-git-master-microlink.vercel.app
sdk-hover-vanilla.microlink.io
sdk-hover-vanilla.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4222c9c Mar 15, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

sdk-vanilla – ./packages/vanilla

sdk-vanilla.microlink.io
sdk-vanilla-git-master-microlink.vercel.app
sdk-vanilla.vercel.app
sdk-vanilla-microlink.vercel.app

Please sign in to comment.