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: instance options (custom) #10

Merged
merged 1 commit into from
May 13, 2022
Merged

feat: instance options (custom) #10

merged 1 commit into from
May 13, 2022

Conversation

wangcch
Copy link
Contributor

@wangcch wangcch commented May 13, 2022

instance?: AxiosInstance;

Customize the Axios instance of the current item.
Override context instance value

const customIns = axios.create({
  // ...
});

function Profile({ userId }) {
  const [{ data, error, isLoading }] = useResource(
    (id) => ({ url: `/user/${id}` }),
    [userId],
    { instance: customIns },
  );

  if (error) return <div>failed to load</div>;
  if (isLoading) return <div>loading...</div>;
  return <div>hello {data.name}!</div>;
}

@wangcch wangcch merged commit 8e1ea2f into v6 May 13, 2022
@wangcch wangcch deleted the feat-custom-instance branch May 13, 2022 14:16
@wangcch wangcch mentioned this pull request May 14, 2022
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

1 participant