Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Prevent componentDidUpdate loop on WorkspaceReimburseSection #14167

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

neil-marcellini
Copy link
Contributor

@neil-marcellini neil-marcellini commented Jan 10, 2023

@arosiclair, @grgia, @aimane-chnaif please take a look at this sneaky bug that slipped through the cracks from my PR.

Details

While reviewing @ctkochan22's PR here I discovered that there was a loop created by calling setState within componentDidUpdate. He pointed out that I also created a very similar loop in the WorkspaceReimburseSection page. I have now fixed that loop by only setting state when the value changes.

Fixed Issues

$ N/A
PROPOSAL: N/A

Tests

  1. Add a console.log line within componentDidUpdate in the WorkspaceReimburseSection.
  2. Follow the test steps from this PR Fetch the bank account for reimburse expenses with offline and loading support #13368.
  3. Make sure that componentDidUpdate is not getting called in a loop in the dev tools console.
  • Verify that no errors appear in the JS console

Offline tests

See the other PR.

QA Steps

No QA

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

The code changes in this PR are not specific to any platform so I only tested on Web.

Web
online.mov
offline.mov
Mobile Web - Chrome

N/A

Mobile Web - Safari

N/A

Desktop

N/A

iOS

N/A

Android

N/A

@neil-marcellini neil-marcellini self-assigned this Jan 10, 2023
@neil-marcellini neil-marcellini marked this pull request as ready for review January 10, 2023 01:04
@neil-marcellini neil-marcellini requested a review from a team as a code owner January 10, 2023 01:04
@melvin-bot melvin-bot bot requested review from Gonals and removed request for a team January 10, 2023 01:05
@melvin-bot
Copy link

melvin-bot bot commented Jan 10, 2023

@Gonals Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@Gonals Gonals merged commit 2ee71ac into main Jan 10, 2023
@Gonals Gonals deleted the neil-reimburse-loop-fix branch January 10, 2023 10:21
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions
Copy link
Contributor

Performance Comparison Report 📊

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Duration
Open Search Page TTI 599.426 ms → 612.622 ms (+13.196 ms, +2.2%)
App start nativeLaunch 9.172 ms → 19.433 ms (+10.261 ms, +111.9%) 🟡
App start TTI 665.768 ms → 672.747 ms (+6.979 ms, +1.0%)
App start runJsBundle 185.938 ms → 191.250 ms (+5.313 ms, +2.9%)
App start regularAppStart 0.015 ms → 0.020 ms (+0.005 ms, +32.7%) 🟡
Show details
Name Duration
Open Search Page TTI Baseline
Mean: 599.426 ms
Stdev: 29.568 ms (4.9%)
Runs: 561.1343590002507 563.179078000132 564.6980800000019 569.282389999833 572.7471519997343 573.0212409999222 575.4783529997803 576.8986410000362 582.4717209995724 583.9607339999638 584.4488119999878 584.7399899996817 585.3886319999583 585.9359949999489 587.6192630003206 588.3706870004535 589.3417149996385 589.7730720001273 592.0485439999029 592.5592849999666 598.2104090000503 599.232503999956 601.5802819998935 609.0370689998381 618.9633790003136 619.6671959999949 628.2468270002864 631.194376999978 632.7601729999296 645.4939379999414 651.8418370001018 652.9004719997756 688.8276370000094

Current
Mean: 612.622 ms
Stdev: 24.321 ms (4.0%)
Runs: 577.3998619997874 580.056478000246 580.6530349999666 583.9944660002366 585.7666020002216 586.3418780001812 586.5604250002652 587.0402839998715 589.1982019999996 590.3861489999108 599.9917810000479 601.1398930000141 602.468423999846 602.7792559997179 603.1122240000404 603.5506190001033 604.241251999978 612.5826820000075 615.5010580001399 620.2717689997517 621.4147140001878 623.753173999954 625.246907999739 626.2974860002287 635.7366540003568 636.7362069999799 637.3928630002774 639.2224129997194 643.5998939997517 646.5923669999465 648.2561039999127 658.8304449999705 660.4158529997803
App start nativeLaunch Baseline
Mean: 9.172 ms
Stdev: 0.949 ms (10.4%)
Runs: 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 11 11 11

Current
Mean: 19.433 ms
Stdev: 1.202 ms (6.2%)
Runs: 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 20 20 20 20 20 20 20 21 21 21 21 22 22
App start TTI Baseline
Mean: 665.768 ms
Stdev: 26.687 ms (4.0%)
Runs: 620.5308159999549 629.3429080001079 632.227864000015 632.2401600000449 632.7110680001788 638.2895479998551 639.1349229998887 644.5013129999861 648.5140410000458 652.9487230000086 652.9743499998003 655.1886450001039 655.6900729998015 658.1030999999493 658.3692789999768 659.6780779999681 660.2979469997808 661.5780639997683 666.217389000114 670.598108000122 673.1484619998373 676.629137000069 679.1302240001969 679.7194610000588 684.1830770000815 690.5617370000109 694.3393450002186 698.6930109998211 709.668730000034 710.8986579999328 716.2950809998438 722.1606049998663

Current
Mean: 672.747 ms
Stdev: 34.373 ms (5.1%)
Runs: 620.8424419998191 631.6303980001248 632.1156640001573 633.5452890000306 635.4363330001943 635.9887170000002 641.9119509998709 643.0875450000167 643.7471610000357 648.0431780000217 648.1686350000091 652.0500869997777 653.3317309999838 662.2290630000643 666.0463450001553 666.8183320001699 667.3780430001207 672.7292160000652 674.9630200001411 689.9669960001484 690.4594089998864 693.9549730001017 697.9935820000246 698.2566660000011 699.9515080000274 709.9205919997767 712.974134999793 716.8457329999655 728.2341740000993 730.2509519997984 756.274954999797
App start runJsBundle Baseline
Mean: 185.938 ms
Stdev: 21.715 ms (11.7%)
Runs: 149 156 161 161 164 166 167 169 169 169 174 175 175 181 182 182 182 183 183 186 186 189 198 202 204 211 211 213 221 226 227 228

Current
Mean: 191.250 ms
Stdev: 22.067 ms (11.5%)
Runs: 159 163 164 167 168 170 171 171 171 175 175 177 177 182 185 185 186 198 200 200 200 201 202 204 206 206 211 216 225 230 232 243
App start regularAppStart Baseline
Mean: 0.015 ms
Stdev: 0.001 ms (9.3%)
Runs: 0.012695000041276217 0.012695000041276217 0.012898999731987715 0.0129399998113513 0.013019999954849482 0.01310200011357665 0.01322399964556098 0.013427999801933765 0.013508999720215797 0.013549999799579382 0.014037999790161848 0.014160000253468752 0.014281999785453081 0.0143630001693964 0.01509599993005395 0.015177000313997269 0.015217999927699566 0.015422000084072351 0.015462000388652086 0.015463000163435936 0.015503000002354383 0.015664999838918447 0.01570699969306588 0.015828000381588936 0.015949999913573265 0.01615400006994605 0.016276000067591667 0.016561000142246485 0.016724000219255686 0.016764000058174133 0.017496999818831682

Current
Mean: 0.020 ms
Stdev: 0.001 ms (4.6%)
Runs: 0.01823000004515052 0.018269999884068966 0.018309999722987413 0.01847400004044175 0.0185139998793602 0.018718000035732985 0.019002999644726515 0.019082999788224697 0.019245999865233898 0.019247000105679035 0.01936900010332465 0.0194089999422431 0.019530999939888716 0.0195720000192523 0.019694000016897917 0.0197350000962615 0.019816000014543533 0.019896999932825565 0.019898000173270702 0.02002000017091632 0.020060000009834766 0.020507999695837498 0.020507999695837498 0.0206300001591444 0.020955999847501516 0.021240000147372484 0.021850999910384417

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @Gonals in version: 1.2.52-0 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.2.52-4 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants