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

[$250] Remove withCurrentReportID HOC #50510

Open
luacmartins opened this issue Oct 9, 2024 · 7 comments
Open

[$250] Remove withCurrentReportID HOC #50510

luacmartins opened this issue Oct 9, 2024 · 7 comments
Assignees
Labels
Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@luacmartins
Copy link
Contributor

luacmartins commented Oct 9, 2024

Coming from here, we should remove the withCurrentReportID HOC in favor of useCurrentReportID hook

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021869425871317443271
  • Upwork Job ID: 1869425871317443271
  • Last Price Increase: 2024-12-18
Issue OwnerCurrent Issue Owner: @dominictb
@luacmartins
Copy link
Contributor Author

Not a priority

@melvin-bot melvin-bot bot removed the Overdue label Nov 13, 2024
@melvin-bot melvin-bot bot added the Overdue label Dec 16, 2024
@luacmartins
Copy link
Contributor Author

Same

@melvin-bot melvin-bot bot removed the Overdue label Dec 18, 2024
@luacmartins luacmartins added Weekly KSv2 External Added to denote the issue can be worked on by a contributor Monthly KSv2 and removed Monthly KSv2 Weekly KSv2 labels Dec 18, 2024
@melvin-bot melvin-bot bot changed the title Remove withCurrentReportID HOC [$250] Remove withCurrentReportID HOC Dec 18, 2024
Copy link

melvin-bot bot commented Dec 18, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 18, 2024
@luacmartins luacmartins added Daily KSv2 and removed Monthly KSv2 labels Dec 18, 2024
Copy link

melvin-bot bot commented Dec 18, 2024

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

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Dec 18, 2024

Edited by proposal-police: This proposal was edited at 2024-12-18 17:02:18 UTC.

Proposal

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

Remove withCurrentReportID HOC

What is the root cause of that problem?

Refactor

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

Replace every usage of withCurrentReportID hoc with useCurrentReportID hook

export default function withCurrentReportID<TProps extends CurrentReportIDContextValue, TRef>(
WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>,
): (props: Omit<TProps, keyof CurrentReportIDContextValue> & React.RefAttributes<TRef>) => React.ReactElement | null {
function WithCurrentReportID(props: Omit<TProps, keyof CurrentReportIDContextValue>, ref: ForwardedRef<TRef>) {
return (
<CurrentReportIDContext.Consumer>

Places to replce the hoc
Report screen

export default withCurrentReportID(memo(ReportScreen, (prevProps, nextProps) => prevProps.currentReportID === nextProps.currentReportID && lodashIsEqual(prevProps.route, nextProps.route)));

And we should check for all used palces

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

Copy link
Contributor

cole Your proposal will be dismissed because you did not follow the proposal template.

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 18, 2024

Proposal

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

Remove withCurrentReportID HOC

What is the root cause of that problem?

Improvement

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

  1. This HOC is only used in ReportScreen, we can replace this with useCurrentReportID hook and update the ReportScreenProps
const {currentReportID} = useCurrentReportID();

export default function withCurrentReportID<TProps extends CurrentReportIDContextValue, TRef>(
WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>,
): (props: Omit<TProps, keyof CurrentReportIDContextValue> & React.RefAttributes<TRef>) => React.ReactElement | null {
function WithCurrentReportID(props: Omit<TProps, keyof CurrentReportIDContextValue>, ref: ForwardedRef<TRef>) {
return (
<CurrentReportIDContext.Consumer>

export default withCurrentReportID(memo(ReportScreen, (prevProps, nextProps) => prevProps.currentReportID === nextProps.currentReportID && lodashIsEqual(prevProps.route, nextProps.route)));

  1. After that we can remove withCurrentReportID file and move all logic of CurrentReportIDContextProvider from withCurrentReportID file to useCurrentReportID file to centralize logic.

export default function withCurrentReportID<TProps extends CurrentReportIDContextValue, TRef>(
WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>,
): (props: Omit<TProps, keyof CurrentReportIDContextValue> & React.RefAttributes<TRef>) => React.ReactElement | null {
function WithCurrentReportID(props: Omit<TProps, keyof CurrentReportIDContextValue>, ref: ForwardedRef<TRef>) {
return (
<CurrentReportIDContext.Consumer>

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

NA

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

4 participants