Skip to content

Commit

Permalink
Use default value for storage
Browse files Browse the repository at this point in the history
  • Loading branch information
zaiste committed May 19, 2023
1 parent b087177 commit 15e7a19
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ The authentication occurs in the React component lifecycle by setting the event
```javascript
const { saleorAuthClient, isAuthenticating } = useSaleorAuthClient({
saleorApiUrl: "https://master.staging.saleor.cloud",
storage: window.localStorage,
});
```

Expand Down Expand Up @@ -164,10 +163,7 @@ useAuthChange({
export const App = () => {
const { saleorApiUrl } = getQueryParams();
const { locale, messages } = useLocale();
const saleorAuthClientProps = useSaleorAuthClient({
saleorApiUrl,
storage: localStorage,
});
const saleorAuthClientProps = useSaleorAuthClient({ saleorApiUrl });

const { saleorAuthClient } = saleorAuthClientProps;

Expand Down Expand Up @@ -213,10 +209,7 @@ useAuthChange({
```jsx
export const App = () => {
const { saleorApiUrl } = getQueryParams();
const saleorAuthClientProps = useSaleorAuthClient({
saleorApiUrl,
storage: localStorage,
});
const saleorAuthClientProps = useSaleorAuthClient({ saleorApiUrl });

const { saleorAuthClient } = saleorAuthClientProps;

Expand Down
2 changes: 1 addition & 1 deletion src/SaleorAuthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { CHECKOUT_CUSTOMER_DETACH, PASSWORD_RESET, TOKEN_CREATE, TOKEN_REFRESH }
export interface SaleorAuthClientProps {
onAuthRefresh?: (isAuthenticating: boolean) => void;
saleorApiUrl: string;
storage: Storage | undefined;
storage?: Storage;
}

export class SaleorAuthClient {
Expand Down
2 changes: 1 addition & 1 deletion src/react/useSaleorAuthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface UseSaleorAuthClient {
*/
export const useSaleorAuthClient = ({
saleorApiUrl,
storage,
storage = typeof window !== "undefined" ? window.localStorage : undefined,
onAuthRefresh,
}: SaleorAuthClientProps): UseSaleorAuthClient => {
const [isAuthenticating, setIsAuthenticating] = useState(false);
Expand Down

0 comments on commit 15e7a19

Please sign in to comment.