-
Notifications
You must be signed in to change notification settings - Fork 133
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
V6 fix initial state upi intent #2921
Conversation
🦋 Changeset detectedLatest commit: 7272a8c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Change: +8 B (0%) Total Size: 755 kB
ℹ️ View Unchanged
|
size-limit report 📦
|
Quality Gate passedIssues Measures |
@@ -34,7 +34,7 @@ export default function UPIComponent({ defaultMode, onChange, onUpdateMode, payB | |||
const { i18n } = useCoreContext(); | |||
const getImage = useImage(); | |||
const [status, setStatus] = useState<UIElementStatus>('ready'); | |||
const [isValid, setIsValid] = useState<boolean>(true); | |||
const [isValid, setIsValid] = useState<boolean>(defaultMode === 'qrCode'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come the v5 version has a constant (defaultMode === UpiMode.QrCode
) but here we're using a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In v6, we use string literals for the UpiMode
, but in v5 we define it as enum, that's why we need to code differently. The reason to change the type definition is because string literals are easier for JS users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an observation: we use the string qrCode
in quite a few places - it just feels like something that could be defined as a constant somewhere.
This is also true in a lot of other places in our codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an observation: we use the string
qrCode
in quite a few places - it just feels like something that could be defined as a constant somewhere. This is also true in a lot of other places in our codebase
It feels a bit too much for this field, as it only allows 3 values and there is already a type guard for it. Typing any other strings throws a Typescript error.
Otherwise we will need to define the UpiMode
like this, so that we can use VPA
, QR_CODE
or INTENT
in the code.
export const VPA = 'vpa';
export const QR_CODE = 'qrCode';
export const INTENT = 'intent';
export type UpiMode = typeof VPA | typeof QR_CODE | typeof INTENT;
Summary
cherry pick from fe369df