Skip to content

Commit

Permalink
fix: fetchFromApi interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Mar 3, 2020
1 parent f2d7ac0 commit c5f010e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/react/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const Card = props => {
const [iframeMedia, setIframeMedia] = useState(null)
const [isError, setIsError] = useState(false)
const isLoadingUndefined = useMemo(() => loading === undefined, [loading])
const [apiUrl, apiUrlProps] = useMemo(() => getApiUrl({ ...props, media: mediaProps }), [mediaProps, props])
const [apiUrl, apiUrlProps] = useMemo(
() => getApiUrl({ ...props, media: mediaProps }),
[mediaProps, props]
)

const isLazyEnabled = useMemo(
() => isLazySupported && (lazy === true || isObject(lazy)),
Expand All @@ -65,7 +68,7 @@ const Card = props => {
setLoading(true)
const fetch = isFunction(setData)
? Promise.resolve({})
: fetchFromApi(url, apiUrl, apiUrlProps)
: fetchFromApi(apiUrl, apiUrlProps)

fetch
.then(({ data }) => mergeData(data))
Expand All @@ -83,7 +86,16 @@ const Card = props => {
? setData()
: { ...fetchedData, ...setData }

const { title, description, url, video, audio, image, logo, iframe } = payload
const {
title,
description,
url,
video,
audio,
image,
logo,
iframe
} = payload

const mediaFallback = image || logo || {}
let media = mediaFallback
Expand Down

0 comments on commit c5f010e

Please sign in to comment.