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

Migrate index.js to function component #16161

Closed
1 task
marcaaron opened this issue Mar 20, 2023 · 51 comments
Closed
1 task

Migrate index.js to function component #16161

marcaaron opened this issue Mar 20, 2023 · 51 comments
Assignees
Labels
Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Weekly KSv2

Comments

@marcaaron
Copy link
Contributor

marcaaron commented Mar 20, 2023

Class Component Migration

Filenames

  • src/components/Hoverable/index.js
    • type: React.Component
    • has state values: true
    • has refs: true
    • has context: false
    • lifecycle methods: componentDidMount,componentWillUnmount

Task

  • We currently have some class components in our codebase that we would like to refactor to a function component.
  • Here's a link with some general advice on how to refactor a class component to a function component: https://react.dev/reference/react/Component#alternatives
  • If you need additional guidance, please ask in #expensify-open-source
  • Test for any regressions and verify that there are no breaking changes
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019c6ea0a458401e24
  • Upwork Job ID: 1701785419929559040
  • Last Price Increase: 2023-10-04
@marcaaron marcaaron added Engineering Improvement Item broken or needs improvement. labels Mar 20, 2023
@melvin-bot melvin-bot bot locked and limited conversation to collaborators Mar 20, 2023
@Expensify Expensify unlocked this conversation Mar 21, 2023
@marcaaron marcaaron changed the title [HOLD] Migrate index.js to function component [HOLD][$250] Migrate index.js to function component Apr 13, 2023
@muxriddinmuqimov77
Copy link

I'd like to work on this issue

@s-alves10
Copy link
Contributor

I'd love to work on this.

@vdem0115
Copy link

vdem0115 commented Jul 5, 2023

I can work on this issue.

1 similar comment
@olexyt
Copy link
Contributor

olexyt commented Jul 7, 2023

I can work on this issue.

@rayane-djouah
Copy link
Contributor

Can I work on this issue?

@mkhutornyi
Copy link
Contributor

I'd like to work on this.

@aditygrg2
Copy link

Hello, I would like to work on this issue.

@kacper-mikolajczak
Copy link
Contributor

kacper-mikolajczak commented Sep 11, 2023

Hi, I am Kacper from Callstack and I’d like to work on this issue :)

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

📣 @kacper-mikolajczak! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@mountiny mountiny added the External Added to denote the issue can be worked on by a contributor label Sep 13, 2023
@mountiny mountiny changed the title [HOLD][$250] Migrate index.js to function component [$250] Migrate index.js to function component Sep 13, 2023
@melvin-bot melvin-bot bot changed the title [$250] Migrate index.js to function component [HOLD][$250] Migrate index.js to function component Sep 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

Job added to Upwork: https://www.upwork.com/jobs/~019c6ea0a458401e24

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

Triggered auto assignment to @peterdbarkerUK (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot melvin-bot bot added the Daily KSv2 label Sep 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ArekChr (External)

@blaw023
Copy link

blaw023 commented Sep 13, 2023

Contributor details
Your Expensify account email: skillgro1@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0167e44d60f727e86a

@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@blaw023
Copy link

blaw023 commented Sep 13, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Migrate src/components/Hoverable/index.js into a functional component.

What is the root cause of that problem?

new feature

What changes do you think we should make in order to solve the problem?

We need to migrate index.js into a functional component. We can do this by using the following hooks:

  • useEffect
  • useRef
  • useState

@melvin-bot melvin-bot bot added the Weekly KSv2 label Oct 18, 2023
@melvin-bot melvin-bot bot changed the title [$250] Migrate index.js to function component [HOLD for payment 2023-10-25] [$250] Migrate index.js to function component Oct 18, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.86-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-25. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@youssef-lr
Copy link
Contributor

@kacper-mikolajczak I'm seeing this in production when I resize to mobile view from the console, could it be related to this PR?

Screenshot 2023-10-19 at 19 06 28

@youssef-lr
Copy link
Contributor

I can confirm that reverting the PR locally fixes it for me

Screen.Recording.2023-10-19.at.19.14.51.mov

@kacper-mikolajczak
Copy link
Contributor

Hi @youssef-lr, it looks like the error is caused by the BoundsObserver + Hoverable combo, which was investigated before and seemed to be fixed. Not for long 😄 Is it critical enough that we want to revert the PR? Wonder if there are more errors, as the original issue is gone.

I will look into it, thanks for the feedback!

@youssef-lr
Copy link
Contributor

Nobody has caught this in staging nor prod yet, so I guess it's not easy to reproduce? Weirdly, when I resize the window manually the error doesn't seem to happen. But pressing CMD+Option+J to reveal dev tools which is already set to mobile view triggers it. So I'm not totally sure about how critical it is..we can wait and find out if it's occurring for more users.

@kacper-mikolajczak
Copy link
Contributor

kacper-mikolajczak commented Oct 19, 2023

Yeah, it stopped crashing "in the app" but still happens with scenario you brought up - interesting 🤔 My first thoughts are:

  • race condition, but that would mean we should have the crash occasionally happening in the original scenario as well and not always when opening the devtools. On the other hand, there is possibility that some listener in BoundsObserver is not being triggered when window changes that fast
  • BoundsObserver + Hoverable seem to have issues with passing refs properly

Hopefully it will be resolved sooner than later 🤞

@kacper-mikolajczak
Copy link
Contributor

@cubuspl42 you might be interested in this 👀 🕵️

@cubuspl42
Copy link
Contributor

If there's any problem with bounds-observer, you can create an issue, I might be able to fix it if there's a bug there!

I'm actually surprised nothing turned up for so long, at least nothing I'm aware of.

@cubuspl42
Copy link
Contributor

Known limitations are listed here

@kacper-mikolajczak
Copy link
Contributor

kacper-mikolajczak commented Oct 19, 2023

Thank you for the feedback! I will try to double check what is causing the issue and if the root cause is indeed on the library side, I will create the issue and hopefully resolve it as well 🤞

@kacper-mikolajczak
Copy link
Contributor

@youssef-lr Here is the continuation of an issue described in #29844 (comment)

@kacper-mikolajczak
Copy link
Contributor

@youssef-lr I've tried to investigate what is causing the app to crash when responsive view is triggered via devtools. I could not really find a proper reason - it looks like it only happens when we open the devtools for the first time:

  • no error when rapidly changing window size
  • no error when going between many screen sizes in devtools' responsive view
  • no error when app is being opened in devtools's responsive view
  • window size does not matter, with larger/smaller screens it's still triggering

It seems that some refs are not being properly attached, or at least not in time for BoundsObserver to be ready, thus BoundsObserver triggers its error based on missing ref.

I tried to prepare reproducible sample with BoundsObserver but it did not give any meaningful results - the app just works.

For today I have no further ideas how to solve the issue. Sorry! I will try to find a way soon!

@youssef-lr
Copy link
Contributor

Thank you so much for digging into this @kacper-mikolajczak, appreciate it!

@kacper-mikolajczak
Copy link
Contributor

kacper-mikolajczak commented Oct 27, 2023

@youssef-lr Here is a solution that should solve the issue here as well: #30278 (comment)

PR is under review 👍

@peterdbarkerUK peterdbarkerUK removed Help Wanted Apply this label when an issue is open to proposals by contributors Awaiting Payment Auto-added when associated PR is deployed to production labels Oct 30, 2023
@peterdbarkerUK peterdbarkerUK changed the title [HOLD for payment 2023-10-25] [$250] Migrate index.js to function component Migrate index.js to function component Oct 30, 2023
@peterdbarkerUK
Copy link
Contributor

Deployed to staging

@melvin-bot melvin-bot bot added the Overdue label Nov 7, 2023
@peterdbarkerUK
Copy link
Contributor

With this now on prod, @youssef-lr can you confirm this is working as expected (and if so, close out the issue)?

@melvin-bot melvin-bot bot removed the Overdue label Nov 7, 2023
@youssef-lr
Copy link
Contributor

Working great @peterdbarkerUK!

@Beamanator
Copy link
Contributor

Woohoo ! That means we can finally close this out? :D

@youssef-lr
Copy link
Contributor

Yup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Weekly KSv2
Projects
None yet
Development

No branches or pull requests