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

feat: use mql as fetcher #162

Merged
merged 13 commits into from
Oct 14, 2019
Merged

feat: use mql as fetcher #162

merged 13 commits into from
Oct 14, 2019

Conversation

Kikobeats
Copy link
Member

No description provided.

@@ -51,7 +51,7 @@ function Microlink (props) {
isLoadingUndefined ? true : loadingProp
)
const [cardData, setCardData] = useState({})
const apiUrl = useMemo(() => createApiUrl(props), [props])
const [apiUrl, apiUrlProps] = useMemo(() => getApiUrl(props), [props])
Copy link
Member Author

@Kikobeats Kikobeats Oct 8, 2019

Choose a reason for hiding this comment

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

getApiUrl is returning two tings:

  • apiUrl (string): The API url for doing the GET request.
  • apiUrlProps (object): some options to be pass to fetch (like headers, etc).

Since this is directly used by useCallback props, I'm not sure if the best thing here is to split them into two different things (the current approach) or pass it as a whole thing, like:

const apiUrlProps = useMemo(() => getApiUrl(props), [props])

// passing it to fetcher
fetchFromApi(props.url, ...apiUrlProps)

// later, on props over `useCallback`
[canFetchData, setData, ...apiUrlProps])

thoughts? 🤔

@Kikobeats
Copy link
Member Author

tests are failing because I need to update snapshots, but first I need your feedback 😂

@Kikobeats Kikobeats changed the title build: use mql as fetcher feat: use mql as fetcher Oct 14, 2019
@Kikobeats Kikobeats merged commit b7eac46 into master Oct 14, 2019
@Kikobeats Kikobeats deleted the next branch October 14, 2019 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants