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

Add context.options dependency #154

Merged
merged 1 commit into from Dec 3, 2019
Merged

Add context.options dependency #154

merged 1 commit into from Dec 3, 2019

Conversation

TheDuc
Copy link
Contributor

@TheDuc TheDuc commented Dec 3, 2019

Changed options, for example new Interceptor when token was changed, were not reflected in the next interceptor call.

part of the code:

const options: Options = useMemo(() => ({
  interceptors: {
    request: async (options) => {
      if (token) {
        (options.headers as any).Authorization = `Bearer ${token}`;
      }

      return options;
    },
  }
}), [token]);

return (
  <Provider url={config.API_URL} options={options}>
    {children}
  </Provider>
);

Adding context.options dependency to useMemo in useFetchArgs solved this issue.

@alex-cory
Copy link
Collaborator

Great work!

@alex-cory alex-cory merged commit 683732a into ava:master Dec 3, 2019
@TheDuc TheDuc deleted the patch-3 branch February 13, 2020 09:37
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