Skip to content

Conversation

digitaljohn
Copy link

Which issue, if any, is this issue related to?

n/a

Is there anything in the PR that needs further explanation?

As the arguments have grown over time the hook is getting trickier to use. This change lets you pass in a configuration object with named variables rather than a long list of arguments.

This allows you for example use the first and last argument (how it was) without needing to specify the middle arguments.

E.g. Old Way:

const { data, loading, error, refresh } = useApi(
  "https://some-api.com",
  0,
  null,
  "get",
  myChangedCallback
);

New way:

const { data, loading, error, refresh } = useApi({
  apiEndpoint: "https://some-api.com",
  changed: myChangedCallback
});

@digitaljohn digitaljohn added the enhancement New feature or request label Sep 27, 2019
@digitaljohn digitaljohn self-assigned this Sep 27, 2019
@digitaljohn digitaljohn requested a review from nattog September 27, 2019 16:18
@digitaljohn digitaljohn merged commit 8c1ab01 into master Sep 27, 2019
@digitaljohn digitaljohn deleted the object-destructuring branch September 27, 2019 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants