Skip to content

Commit

Permalink
fix: memoize signIn and signOut (#143)
Browse files Browse the repository at this point in the history
* fix: memoize signIn/signOut

* chore: add changeset

* chore: bump package versions
  • Loading branch information
horsefacts authored Feb 15, 2024
1 parent 814743b commit b5ad5ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/auth-kit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @farcaster/auth-kit

## 0.2.1

### Patch Changes

- 1bee0fb: fix: memoize signIn/signOut in useSignIn

## 0.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@farcaster/auth-kit",
"version": "0.2.0",
"version": "0.2.1",
"type": "module",
"main": "./dist/auth-kit.js",
"types": "./dist/auth-kit.d.ts",
Expand Down
10 changes: 5 additions & 5 deletions packages/auth-kit/src/hooks/useSignIn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthClientError, StatusAPIResponse } from "@farcaster/auth-client";
import { useEffect } from "react";
import { useCallback, useEffect } from "react";

import useAppClient from "./useAppClient";
import useCreateChannel, { UseCreateChannelArgs } from "./useCreateChannel";
Expand Down Expand Up @@ -74,14 +74,14 @@ export function useSignIn(args: UseSignInArgs) {
const isError = isCreateChannelError || isWatchStatusError || isVerifyError;
const error = createChannelError || watchStatusError || verifyError;

const signIn = () => {
const signIn = useCallback(() => {
watch();
};
}, [watch]);

const signOut = () => {
const signOut = useCallback(() => {
onSignOut();
reset();
};
}, [onSignOut, reset]);

useEffect(() => {
if (isSuccess && statusData && validSignature) {
Expand Down

0 comments on commit b5ad5ec

Please sign in to comment.