Skip to content

Commit 96b3727

Browse files
committed
fix React Hook dependency warning in NostrExtensionCheck
Wrap checkExtension with useCallback and include it in useEffect dependencies to resolve exhaustive-deps warning.
1 parent 8b8ee1f commit 96b3727

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/auth/NostrExtensionCheck/NostrExtensionCheck.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useCallback } from 'react';
22
import { Alert, Card, Button, Space, Typography } from 'antd';
33
import { ExclamationCircleOutlined, CheckCircleOutlined, ReloadOutlined } from '@ant-design/icons';
44
import styled from 'styled-components';
@@ -109,7 +109,7 @@ export const NostrExtensionCheck: React.FC<NostrExtensionCheckProps> = ({ onExte
109109
const [hasExtension, setHasExtension] = useState(false);
110110
const [isChecking, setIsChecking] = useState(true);
111111

112-
const checkExtension = () => {
112+
const checkExtension = useCallback(() => {
113113
setIsChecking(true);
114114

115115
// Check if window.nostr exists
@@ -120,7 +120,7 @@ export const NostrExtensionCheck: React.FC<NostrExtensionCheckProps> = ({ onExte
120120
if (extensionExists && onExtensionReady) {
121121
onExtensionReady();
122122
}
123-
};
123+
}, [onExtensionReady]);
124124

125125
useEffect(() => {
126126
// Initial check
@@ -135,7 +135,7 @@ export const NostrExtensionCheck: React.FC<NostrExtensionCheckProps> = ({ onExte
135135
}, 1000);
136136

137137
return () => clearInterval(pollInterval);
138-
}, [hasExtension, onExtensionReady]);
138+
}, [hasExtension, checkExtension]);
139139

140140
const extensions = [
141141
{

0 commit comments

Comments
 (0)