Skip to content

improved immutable errors #593

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/components/CheckoutProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ describe('CheckoutProvider', () => {
expect(mockStripe.initCheckout).toHaveBeenCalledTimes(1);
expect(mockStripe2.initCheckout).toHaveBeenCalledTimes(0);
expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on CheckoutProvider: You cannot change the `stripe` prop after setting it.'
'[stripe] Unsupported prop change on CheckoutProvider: You cannot change the `stripe` prop after setting it.'
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/CheckoutProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export const CheckoutProvider: FunctionComponent<PropsWithChildren<
const prevStripe = usePrevious(rawStripeProp);
React.useEffect(() => {
if (prevStripe !== null && prevStripe !== rawStripeProp) {
console.warn(
'Unsupported prop change on CheckoutProvider: You cannot change the `stripe` prop after setting it.'
console.error(
'[stripe] Unsupported prop change on CheckoutProvider: You cannot change the `stripe` prop after setting it.'
);
}
}, [prevStripe, rawStripeProp]);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Elements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('Elements', () => {
expect(mockStripe.elements.mock.calls).toHaveLength(1);
expect(mockStripe2.elements.mock.calls).toHaveLength(0);
expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.'
'[stripe] Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.'
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/Elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export const Elements: FunctionComponent<PropsWithChildren<ElementsProps>> = (({
const prevStripe = usePrevious(rawStripeProp);
React.useEffect(() => {
if (prevStripe !== null && prevStripe !== rawStripeProp) {
console.warn(
'Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.'
console.error(
'[stripe] Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.'
);
}
}, [prevStripe, rawStripeProp]);
Expand Down
12 changes: 6 additions & 6 deletions src/components/EmbeddedCheckoutProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('EmbeddedCheckoutProvider', () => {
expect(mockStripe.initEmbeddedCheckout.mock.calls).toHaveLength(1);
expect(mockStripe2.initEmbeddedCheckout.mock.calls).toHaveLength(0);
expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.'
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.'
);
});

Expand Down Expand Up @@ -275,7 +275,7 @@ describe('EmbeddedCheckoutProvider', () => {
);

expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
);
});
});
Expand Down Expand Up @@ -329,7 +329,7 @@ describe('EmbeddedCheckoutProvider', () => {
);

expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
);
});
});
Expand Down Expand Up @@ -378,7 +378,7 @@ describe('EmbeddedCheckoutProvider', () => {
);

expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.'
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.'
);
});

Expand Down Expand Up @@ -410,7 +410,7 @@ describe('EmbeddedCheckoutProvider', () => {
);

expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it.'
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it.'
);
});

Expand Down Expand Up @@ -441,7 +441,7 @@ describe('EmbeddedCheckoutProvider', () => {
></EmbeddedCheckoutProvider>
);
expect(consoleWarn).toHaveBeenCalledWith(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.'
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.'
);
});

Expand Down
28 changes: 14 additions & 14 deletions src/components/EmbeddedCheckoutProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ export const EmbeddedCheckoutProvider: FunctionComponent<PropsWithChildren<
const prevStripe = usePrevious(rawStripeProp);
React.useEffect(() => {
if (prevStripe !== null && prevStripe !== rawStripeProp) {
console.warn(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.'
console.error(
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.'
);
}
}, [prevStripe, rawStripeProp]);
Expand All @@ -173,8 +173,8 @@ export const EmbeddedCheckoutProvider: FunctionComponent<PropsWithChildren<
}

if (options == null) {
console.warn(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them.'
console.error(
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them.'
);
return;
}
Expand All @@ -192,44 +192,44 @@ export const EmbeddedCheckoutProvider: FunctionComponent<PropsWithChildren<
prevOptions.clientSecret != null &&
options.clientSecret !== prevOptions.clientSecret
) {
console.warn(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
console.error(
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
);
}

if (
prevOptions.fetchClientSecret != null &&
options.fetchClientSecret !== prevOptions.fetchClientSecret
) {
console.warn(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
console.error(
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'
);
}

if (
prevOptions.onComplete != null &&
options.onComplete !== prevOptions.onComplete
) {
console.warn(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.'
console.error(
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.'
);
}

if (
prevOptions.onShippingDetailsChange != null &&
options.onShippingDetailsChange !== prevOptions.onShippingDetailsChange
) {
console.warn(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it.'
console.error(
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it.'
);
}

if (
prevOptions.onLineItemsChange != null &&
options.onLineItemsChange !== prevOptions.onLineItemsChange
) {
console.warn(
'Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.'
console.error(
'[stripe] Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.'
);
}
}, [prevOptions, options]);
Expand Down
2 changes: 1 addition & 1 deletion src/components/createElementComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ describe('createElementComponent', () => {
expect(mockElement.update).not.toHaveBeenCalled();

expect(console.warn).toHaveBeenCalledWith(
'Unsupported prop change: options.paymentRequest is not a mutable property.'
'[stripe] Unsupported prop change: options.paymentRequest is not a mutable property.'
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/extractAllowedOptionsUpdates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('extractAllowedOptionsUpdates', () => {
)
).toEqual(null);
expect(consoleSpy).toHaveBeenCalledWith(
'Unsupported prop change: options.foo is not a mutable property.'
'[stripe] Unsupported prop change: options.foo is not a mutable property.'
);
expect(consoleSpy).toHaveBeenCalledTimes(1);

Expand Down
4 changes: 2 additions & 2 deletions src/utils/extractAllowedOptionsUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const extractAllowedOptionsUpdates = (

if (immutableKeys.includes(key)) {
if (isUpdated) {
console.warn(
`Unsupported prop change: options.${key} is not a mutable property.`
console.error(
`[stripe] Unsupported prop change: options.${key} is not a mutable property.`
);
}

Expand Down