#bachir_next-render-issue

1 messages · Page 1 of 1 (latest)

open tundraBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1416060304835743797

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

outer garden
sage apex
#

hey there -- you mentioned one of the things you tried was updating @stripe/stripe-js to 7.x

#

if you did this, you app should load basil Stripe.js instead of v3 so something seems to be happening different than you expect

outer garden
#

Indeed, it was basil instead of v3, but the Violation message was still the same

sage apex
#

Ok as a first pass, I'm not seeing this on my own demo using react/next

#

Is your app publicly accessible anywhere for direct inspection?

open tundraBOT
outer garden
#

No public access unfortunately, and it only happen when running next dev, not when building the app.

sage apex
#

And you say you experience some kind of blocking delay?

#

What does your stripe/elements initialization look like?

outer garden
#

Yes all inputs on the page where the PaymentElement is rendered takes few seconds to focus/register input etc...

import { PaymentElement as StripePaymentElement, useElements } from "@stripe/react-stripe-js";
...
const elements = useElements();
const onReady = useCallback(() => {
  // Once the stripe elements are ready, we can restore the original payment method types after a short delay
  if (restoreStripePaymentMethods.current) {
    restoreStripePaymentMethods.current = false;
    setTimeout(() => {
      elements?.update({ paymentMethodTypes: stripePaymentMethodTypes });
    }, 600);
  }
}, [elements, stripePaymentMethodTypes]);

const paymentMethodOptions: StripePaymentElementOptions = useMemo(
  () => ({
    business: { name: organization.name },
    fields: {
      billingDetails: {
        name: "never",
        email: "never",
        address: "never",
      },
    },
    wallets: { googlePay: "never", applePay: "never" },
    layout: {
      type: showCustomAccordion ? "tabs" : "accordion",
      defaultCollapsed: displayExpressCheckout,
      ...(!showCustomAccordion && { radios: true }), // radios is only available for accordion layout
    } as LayoutObject,
    paymentMethodOrder: prioritizeBankPayment
      ? [STRIPE_PAYMENT_METHOD_FROM_PAYMENT_METHOD.ach, STRIPE_PAYMENT_METHOD_FROM_PAYMENT_METHOD.card]
      : [STRIPE_PAYMENT_METHOD_FROM_PAYMENT_METHOD.card, STRIPE_PAYMENT_METHOD_FROM_PAYMENT_METHOD.ach],
  }),
  [organization.name, showCustomAccordion, displayExpressCheckout, prioritizeBankPayment]
);

...

return (
    <StripePaymentElement
      key={prioritizeBankPayment ? "prioritizeBankPayment" : "cardFirst"}
      id="payment-element"
      // When have a handler on our custom accordion, so this one becomes redundant
      onChange={showCustomAccordion ? undefined : handleStripePaymentMethodChange}
      options={paymentMethodOptions}
      onReady={onReady}
    />
)

I truncated a lot of code, but that's the gist of it.

#

I didn't add the part with ExpressCheckout component, but I don't think it's related here

sage apex
#

An what about the <Elements /> provider outside that?

#

This seems pretty normal, though i dont understand what your showCustomAccordion logic is about

outer garden
#

  const stripeInstance = useMemo(() => {
    const stripePublicApiKey =
      organization.country === OrganizationCountry.Canada
        ? (process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY_CA as string)
        : organization.country === OrganizationCountry.GreatBritain
          ? (process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY_UK as string)
          : (process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY_USA as string);

    return loadStripe(stripePublicApiKey, { locale: serializeLocale(locale) });
  }, [shouldLoadStripe, locale, organization.country]);

<StripeContext.Provider
  value={{
    hasPad,
    hasAch,
    stripePaymentMethodTypes,
    stripePaymentMethods,
    zeffyPaymentMethods,
    expressCheckoutWallet,
    setExpressCheckoutWallet,
    initializeStripe,
  }}
>
  <Elements key={locale} stripe={stripeInstance} options={options}>
    {children}
  </Elements>
</StripeContext.Provider>
sage apex
#

Yes all inputs on the page where the PaymentElement is rendered takes few seconds to focus/register input etc
That should be the case, if I put additional inputs on my page they are interactive even while Payment ELement is initializing.

#

Can you disable/suppress the payment element entirely and see if that changes the behaviour?

#

I'm also assuming that StripeContext.Provider is something for your own app logic, since it doesnt look like anything we maintain

sage apex
#

It's also suspicious that you say you observe this in the next dev server, but not after a build

outer garden
#

im double checkin that too

#

Confirmed that without the PaymentElement, it's working well - no latency on inputs

sage apex
#

Ok then next I'd suggest trying <Elements /> and <PaymentElement /> with stripped-down options and handlers. eg:

  • Remove the ready/change handlers
  • remove the custom key
  • try a static/basic options

If you can remove your wrapping provider too that'd help isolate things.

outer garden
sage apex
#

Essentially we'd need to narrow this down to a minimal repro, since I don't see these warnings or any such delay in a minimal example currently

outer garden
#

Thanks, trying this

sage apex
#

I can stay on here a bit longer to help, but if this will take some time to strip down and you want to continue with context we can convert to an email support case

#

Otherwise when i step away later my colleague can continue helping you poke at this until you isolate it

outer garden
#

The easiest for you really, email works for me too

sage apex
#

Our friendly helper bot will send you a DM with a link you can click!

open tundraBOT
#

Hello @outer garden, we have sent you a direct message, please check it at https://discord.com/channels/@me/1315672023623667856

  • 🔗The message has instructions on how to open a direct support case with our Developer Support team, in order to help you more effectively.