From d1c5d55e13b3ddac5fbc6f8b5ed422a598484417 Mon Sep 17 00:00:00 2001 From: Daniella Mesquita Date: Wed, 17 Jul 2024 13:10:24 -0300 Subject: [PATCH 1/2] Prepare for the next commit (AI Coding) --- .gitmeta/.gitmeta | 23 ++++++ .gitmeta/cids.txt | 2 + .gitmeta/cids_detailed/files-only.txt | 1 + .gitmeta/cids_detailed/with-sha1.txt | 3 + .../layout/header/AIConversation.txt | 75 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 .gitmeta/.gitmeta create mode 100644 .gitmeta/cids.txt create mode 100644 .gitmeta/cids_detailed/files-only.txt create mode 100644 .gitmeta/cids_detailed/with-sha1.txt create mode 100644 template/web/src/components/layout/header/AIConversation.txt diff --git a/.gitmeta/.gitmeta b/.gitmeta/.gitmeta new file mode 100644 index 00000000..80573717 --- /dev/null +++ b/.gitmeta/.gitmeta @@ -0,0 +1,23 @@ +commit QmPG6fcpCEMzssWuV3gSkpxuDgrsxwMtTT1aYbWsHFzZdY +Branch: pr-lint +Signed-off by: danimesq.eth (0xDDfC2e10702d8A781727A34D83B3bb3CA94a3E91) +Signature: 157c328e9fcd470190eafcbf1be347ea865db4db9d918b18158efefca633e664750be0b40f42e6ceb66fea8a65dbf19e38ffb304fdce2ac2ce8a2064d50269b800 + +------------------------------ + +Commit CID if including git's SHA1: QmTgC8oSh1mTLNtuAY4UtfPVzadAfMfQQTNqvxXj1jtY7P +Commit CID if containing only file hashes: QmdxCtC2wXKzDCZKrMR1KTP6LtpEoJRmTeT6PySboyQqqg + +------------------------------ + +.gitmeta version: r8 +Local folder: /home/daniella/Desktop/Untitled Folder 2/build-onchain-apps +Remote Name: origin +Remote URL: https://github.com/FrameworkJavascript/build-onchain-apps.git + +------------------------------ + +chown -h 1000:1000 'template/web/src/components/layout/header/AIConversation.txt' +chmod 0664 'template/web/src/components/layout/header/AIConversation.txt' +/usr/bin/touch -hcmd "2024-07-17 13:10:01.3449380640 -0300" 'template/web/src/components/layout/header/AIConversation.txt' +/usr/bin/touch -hcad "2024-07-17 13:10:24.2280836510 -0300" 'template/web/src/components/layout/header/AIConversation.txt' diff --git a/.gitmeta/cids.txt b/.gitmeta/cids.txt new file mode 100644 index 00000000..59405ebe --- /dev/null +++ b/.gitmeta/cids.txt @@ -0,0 +1,2 @@ +QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH +QmRYugw7RttbecqTtnRGdqme5QsAX45SfGdLRujvEgEbjF diff --git a/.gitmeta/cids_detailed/files-only.txt b/.gitmeta/cids_detailed/files-only.txt new file mode 100644 index 00000000..c277f9bf --- /dev/null +++ b/.gitmeta/cids_detailed/files-only.txt @@ -0,0 +1 @@ +QmRYugw7RttbecqTtnRGdqme5QsAX45SfGdLRujvEgEbjF diff --git a/.gitmeta/cids_detailed/with-sha1.txt b/.gitmeta/cids_detailed/with-sha1.txt new file mode 100644 index 00000000..3f8c8672 --- /dev/null +++ b/.gitmeta/cids_detailed/with-sha1.txt @@ -0,0 +1,3 @@ +QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH +74c5348f67e3801eac793a7f96d684b5795e4c5b +QmRYugw7RttbecqTtnRGdqme5QsAX45SfGdLRujvEgEbjF diff --git a/template/web/src/components/layout/header/AIConversation.txt b/template/web/src/components/layout/header/AIConversation.txt new file mode 100644 index 00000000..bc208a53 --- /dev/null +++ b/template/web/src/components/layout/header/AIConversation.txt @@ -0,0 +1,75 @@ +./src/components/layout/header/AccountConnect.tsx +38:30 Warning: JSX attribute values should not contain functions created in the same scope react-perf/jsx-no-new-function-as-prop + + + + + + + +The warning you're seeing is due to passing a new function as a prop directly within the JSX. This can lead to performance issues because the function will be recreated on every render, causing React components that rely on this prop to re-render unnecessarily. + +In your `AccountConnect.tsx` file, you're creating a new function for the `onClick` handler directly in the JSX: + + +```37:38:AccountConnect.tsx + return ( + + ); + } + + return ( + <> +
+ +
+
+ +
+ + ); + })()} + + ); +} +``` + +By using `useCallback`, you ensure that the function `handleDisconnect` is memoized and only recreated when its dependencies change, thus adhering to best practices for performance in React. From 91d2285b036694dde65cf0cde8a56d195056cc42 Mon Sep 17 00:00:00 2001 From: "Cursor.so" Date: Wed, 17 Jul 2024 13:12:57 -0300 Subject: [PATCH 2/2] AccountConnect.tsx: lint fix "JSX attribute values should not contain functions created in the same scope" - Human implement CursorGPT's coding --- .gitmeta/.gitmeta | 23 ------ .gitmeta/cids.txt | 2 - .gitmeta/cids_detailed/files-only.txt | 1 - .gitmeta/cids_detailed/with-sha1.txt | 3 - .../layout/header/AIConversation.txt | 75 ------------------- .../layout/header/AccountConnect.tsx | 9 ++- 6 files changed, 7 insertions(+), 106 deletions(-) delete mode 100644 .gitmeta/.gitmeta delete mode 100644 .gitmeta/cids.txt delete mode 100644 .gitmeta/cids_detailed/files-only.txt delete mode 100644 .gitmeta/cids_detailed/with-sha1.txt delete mode 100644 template/web/src/components/layout/header/AIConversation.txt diff --git a/.gitmeta/.gitmeta b/.gitmeta/.gitmeta deleted file mode 100644 index 80573717..00000000 --- a/.gitmeta/.gitmeta +++ /dev/null @@ -1,23 +0,0 @@ -commit QmPG6fcpCEMzssWuV3gSkpxuDgrsxwMtTT1aYbWsHFzZdY -Branch: pr-lint -Signed-off by: danimesq.eth (0xDDfC2e10702d8A781727A34D83B3bb3CA94a3E91) -Signature: 157c328e9fcd470190eafcbf1be347ea865db4db9d918b18158efefca633e664750be0b40f42e6ceb66fea8a65dbf19e38ffb304fdce2ac2ce8a2064d50269b800 - ------------------------------- - -Commit CID if including git's SHA1: QmTgC8oSh1mTLNtuAY4UtfPVzadAfMfQQTNqvxXj1jtY7P -Commit CID if containing only file hashes: QmdxCtC2wXKzDCZKrMR1KTP6LtpEoJRmTeT6PySboyQqqg - ------------------------------- - -.gitmeta version: r8 -Local folder: /home/daniella/Desktop/Untitled Folder 2/build-onchain-apps -Remote Name: origin -Remote URL: https://github.com/FrameworkJavascript/build-onchain-apps.git - ------------------------------- - -chown -h 1000:1000 'template/web/src/components/layout/header/AIConversation.txt' -chmod 0664 'template/web/src/components/layout/header/AIConversation.txt' -/usr/bin/touch -hcmd "2024-07-17 13:10:01.3449380640 -0300" 'template/web/src/components/layout/header/AIConversation.txt' -/usr/bin/touch -hcad "2024-07-17 13:10:24.2280836510 -0300" 'template/web/src/components/layout/header/AIConversation.txt' diff --git a/.gitmeta/cids.txt b/.gitmeta/cids.txt deleted file mode 100644 index 59405ebe..00000000 --- a/.gitmeta/cids.txt +++ /dev/null @@ -1,2 +0,0 @@ -QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH -QmRYugw7RttbecqTtnRGdqme5QsAX45SfGdLRujvEgEbjF diff --git a/.gitmeta/cids_detailed/files-only.txt b/.gitmeta/cids_detailed/files-only.txt deleted file mode 100644 index c277f9bf..00000000 --- a/.gitmeta/cids_detailed/files-only.txt +++ /dev/null @@ -1 +0,0 @@ -QmRYugw7RttbecqTtnRGdqme5QsAX45SfGdLRujvEgEbjF diff --git a/.gitmeta/cids_detailed/with-sha1.txt b/.gitmeta/cids_detailed/with-sha1.txt deleted file mode 100644 index 3f8c8672..00000000 --- a/.gitmeta/cids_detailed/with-sha1.txt +++ /dev/null @@ -1,3 +0,0 @@ -QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH -74c5348f67e3801eac793a7f96d684b5795e4c5b -QmRYugw7RttbecqTtnRGdqme5QsAX45SfGdLRujvEgEbjF diff --git a/template/web/src/components/layout/header/AIConversation.txt b/template/web/src/components/layout/header/AIConversation.txt deleted file mode 100644 index bc208a53..00000000 --- a/template/web/src/components/layout/header/AIConversation.txt +++ /dev/null @@ -1,75 +0,0 @@ -./src/components/layout/header/AccountConnect.tsx -38:30 Warning: JSX attribute values should not contain functions created in the same scope react-perf/jsx-no-new-function-as-prop - - - - - - - -The warning you're seeing is due to passing a new function as a prop directly within the JSX. This can lead to performance issues because the function will be recreated on every render, causing React components that rely on this prop to re-render unnecessarily. - -In your `AccountConnect.tsx` file, you're creating a new function for the `onClick` handler directly in the JSX: - - -```37:38:AccountConnect.tsx - return ( - - ); - } - - return ( - <> -
- -
-
- -
- - ); - })()} - - ); -} -``` - -By using `useCallback`, you ensure that the function `handleDisconnect` is memoized and only recreated when its dependencies change, thus adhering to best practices for performance in React. diff --git a/template/web/src/components/layout/header/AccountConnect.tsx b/template/web/src/components/layout/header/AccountConnect.tsx index 710b7cd9..cfb84d47 100644 --- a/template/web/src/components/layout/header/AccountConnect.tsx +++ b/template/web/src/components/layout/header/AccountConnect.tsx @@ -1,3 +1,4 @@ +import { useCallback } from 'react'; import { ConnectAccount } from '@coinbase/onchainkit/wallet'; import { baseSepolia } from 'viem/chains'; import { useAccount, useChainId, useConnect, useDisconnect } from 'wagmi'; @@ -16,6 +17,10 @@ function AccountConnect() { const { disconnect } = useDisconnect(); const chainId = useChainId(); + const handleDisconnect = useCallback(() => { + disconnect(); + }, [disconnect]); + return (
disconnect()} type="button"> + ); @@ -56,4 +61,4 @@ function AccountConnect() { ); } -export default AccountConnect; +export default AccountConnect; \ No newline at end of file