alan2207 / react-query-auth

⚛️ Authenticate your react applications easily with react-query.
MIT License
367 stars 43 forks source link

AuthProviderConfig logoutFn parameter should not be strictly empty #4

Closed AO19 closed 3 years ago

AO19 commented 3 years ago

Is there a disadvantage of setting AuthProviderConfig like this:

export interface AuthProviderConfig<User = unknown, Error = unknown> {
    key?: string;
    loadUser: (data: any) => Promise<User>;
    loginFn: (data: any) => Promise<User>;
    registerFn: (data: any) => Promise<User>;
    logoutFn: (data?: any) => Promise<any>;
    waitInitial?: boolean;
    LoaderComponent?: () => JSX.Element;
    ErrorComponent?: ({ error }: {
        error: Error | null;
    }) => JSX.Element;
}

Otherwise I was not able to set the logoutFn with a parameter.

Original:

export interface AuthProviderConfig<User = unknown, Error = unknown> {
    key?: string;
    loadUser: (data: any) => Promise<User>;
    loginFn: (data: any) => Promise<User>;
    registerFn: (data: any) => Promise<User>;
    logoutFn: () => Promise<any>;
    waitInitial?: boolean;
    LoaderComponent?: () => JSX.Element;
    ErrorComponent?: ({ error }: {
        error: Error | null;
    }) => JSX.Element;
}

@alan2207 what are your thoughts on this? Should I open a pull request or is there something incorrect with this proposal?

alan2207 commented 3 years ago

Hey @AO19, a PR is a good idea. If someone has its use case to provide something to the logout function, let's allow it. So please open a PR for this and I will merge it.

Thanks!