Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/hosted-widget-integration/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": ["../../.eslintrc.json"],
"rules": {
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unnecessary-condition": "off"
"@typescript-eslint/no-unnecessary-condition": "off",
"react-hooks/exhaustive-deps": "off"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to ignore a rule when necessary than to ignore it for the whole package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitalii-koshovyi Thanks for reviewing my PRs.

The react-hooks/exhaustive-deps rule is a bit special. We’ve already disabled it in several packages (e.g., core, braintree-integration) because, in our context, useEffect often can’t depend on all variables without causing unexpected re-renders.

I’m thinking it might make sense to open a PR to disable this rule project-wide, since it’s already off in major packages.

"react-hooks/exhaustive-deps": "off", // 18 errors

"react-hooks/exhaustive-deps": "off"

cc @animesh1987

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For packages we should have the rules in one place for better tracking, rather than in individual files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus what @bc-peng said, the shared payment methods have quite a bit of variance per method that cause different behaviours.

}
}
31 changes: 31 additions & 0 deletions packages/hosted-widget-integration/src/EditButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import classNames from 'classnames';
import React, { type ReactNode } from 'react';

import { preventDefault } from '@bigcommerce/checkout/dom-utils';
import { TranslatedString } from '@bigcommerce/checkout/locale';

interface EditButtonProps {
buttonId: string | undefined;
shouldShowEditButton: boolean | undefined;
}

export const EditButton = ({ buttonId, shouldShowEditButton }: EditButtonProps): ReactNode => {
if (shouldShowEditButton) {
const translatedString = <TranslatedString id="remote.select_different_card_action" />;

return (
<p>
<button
className={classNames('stepHeader', 'widget-link-amazonpay')}
id={buttonId}
onClick={preventDefault()}
type="button"
>
{translatedString}
</button>
</p>
);
}

return null;
};
Loading