1

I'm trying to create a payment screen in React using Recurly.js. I'm using the official React library and am trying to hook into the set.plan event to retrieve plan information. I previously did this without issue using vanilla Recurly.js in Angular, but I haven't been able to do so in React and it's not clear to me if I'm doing something wrong or if there's a bug.

I adapted one of the Interactive Demo scenarios to demonstrate this. Please see the comments added in my sandbox:

const [{ price, loading }, setPricing, checkoutPricing] = useCheckoutPricing(
  null,
  setRecurlyError
);

useEffect(() => {
  /*
    Should this be called frequently? I know the price state gets updated, but I would not
    expect to constantly receive a new/updated instance of checkoutPricing.
  */
  console.log("checkoutPricing updated", checkoutPricing);

  /*
    This never gets called even after selecting a new plan in the dropdown menu
    */
  checkoutPricing.on("set.plan", (plan) => {
    console.log("plan updated", plan);
  });
}, [checkoutPricing]);

Am I getting a new instance of checkoutPricing on each render? That might explain why my event is never firing, but I'm not sure how to avoid that.

JKasper11
  • 772
  • 1
  • 7
  • 21
  • were you ever able to figure this out? – cfnerd Nov 02 '22 at 21:50
  • 1
    @cfnerd Recurly support was beyond painful to deal with, but after more than a month they acknowledged there's an issue with the React library. They submitted the feedback to their product team but made no commitment to fixing it. – JKasper11 Nov 03 '22 at 03:29

0 Answers0