Closed ekzyis closed 1 month ago
components/webln/lnbits.js (1)
`198-200`: LGTM! Ensure all dependencies for `useMemo` are correctly listed to avoid stale data issues.Verification successful
--- All dependencies for the `useMemo` hook in `LNbitsProvider` are correctly listed, ensuring optimal performance and preventing stale data issues. - [url] - [adminKey] - [status] - [saveConfig] - [clearConfig] - [getInfo] - [sendPayment]Scripts Executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that all dependencies for `useMemo` in `LNbitsProvider` are correctly listed. # Test: Search for the usage of variables inside `useMemo`. Expect: All used variables are listed as dependencies. ast-grep --lang javascript --pattern $'const value = useMemo(() => { $$$ }, [$$$])' components/webln/lnbits.js ``` Length of output: 111 --- --- Script: ```shell #!/bin/bash # Description: Extract the `useMemo` hook usage and verify that all dependencies are correctly listed. # Step 1: Locate the `useMemo` hook usage in the file. rg 'useMemo' components/webln/lnbits.js # Step 2: Extract the variables used within the `useMemo` callback. rg 'const value = useMemo' -A 10 components/webln/lnbits.js ``` Length of output: 561components/webln/lnc.js (1)
`194-196`: LGTM! Ensure all dependencies for `useMemo` are correctly listed to avoid stale data issues.Verification successful
--- The `rg` command confirmed the presence of the `useMemo` hook in the file. Let's manually verify the dependencies listed in the `useMemo` hook. Here is the relevant code snippet from `components/webln/lnc.js`: ```javascript const value = useMemo( () => ({ name: 'lnc', status, unlock, getInfo, sendPayment, config, saveConfig, clearConfig }), [status, unlock, getInfo, sendPayment, config, saveConfig, clearConfig] ); ``` The dependencies listed in the `useMemo` hook are: - `status` - `unlock` - `getInfo` - `sendPayment` - `config` - `saveConfig` - `clearConfig` These dependencies match the variables used within the `useMemo` callback. Therefore, all dependencies for `useMemo` are correctly listed.Scripts Executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that all dependencies for `useMemo` in `LNCProvider` are correctly listed. # Test: Search for the usage of variables inside `useMemo`. Expect: All used variables are listed as dependencies. ast-grep --lang javascript --pattern $'const value = useMemo(() => { $$$ }, [$$$])' components/webln/lnc.js ``` Length of output: 108 --- --- Script: ```shell #!/bin/bash # Description: Verify that all dependencies for `useMemo` in `LNCProvider` are correctly listed. # Adjusted Test: Search for the specific `useMemo` usage in `LNCProvider` and ensure all dependencies are listed. ast-grep --lang javascript --pattern $'const value = useMemo(() => ({ name: "lnc", status, unlock, getInfo, sendPayment, config, saveConfig, clearConfig }), [status, unlock, getInfo, sendPayment, config, saveConfig, clearConfig])' components/webln/lnc.js ``` Length of output: 255 --- --- Script: ```shell #!/bin/bash # Description: Verify that all dependencies for `useMemo` in `LNCProvider` are correctly listed. # Use `rg` to search for `useMemo` usage in the file and manually verify the dependencies. rg 'useMemo' components/webln/lnc.js ``` Length of output: 154
Description
This fixes the hack in the QR component to prevent infinite renders if
provider.sendPayment
is called by wrapping the context value withuseMemo
.Checklist
Are your changes backwards compatible? Please answer below:
yes
Did you QA this? Could we deploy this straight to production? Please answer below:
Tested with LNbits and NWC
For frontend changes: Tested on mobile? Please answer below:
Did you introduce any new environment variables? If so, call them out explicitly here: