Skip to content
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

this.context is undefined in ThreeDSecureAction #223

Closed
Silviu-Marian opened this issue Jan 11, 2024 · 4 comments
Closed

this.context is undefined in ThreeDSecureAction #223

Silviu-Marian opened this issue Jan 11, 2024 · 4 comments
Labels

Comments

@Silviu-Marian
Copy link

Silviu-Marian commented Jan 11, 2024

it's referencing this.context in the constructor, despite performing an earlier check a few lines above for context passed as constructor argument

To Reproduce

Simply utilize that component.

Expected behavior

Do not throw.

Your Environment

  • @recurly/react-recurly@1.2.6
  • react@16.14.0
  • Latest Chrome
@chrissrogers
Copy link
Member

I think I'd like to learn a bit more about how this occurs. We'd normally expect the PureComponent constructor to assign that value (see src). I think it's safe to assume that you're rendering the component within a RecurlyContext.

@Silviu-Marian
Copy link
Author

Unintentionally missed mentioning that we're using preact and it looks like their PureComponent implementation completely disregards context.

We patched this 2 weeks ago by duplicating ThreeDSecureAction and changing this.context to context. It solved the issue.

I'm not sure now if we should close this issue and file one with preact, or leave it open and ask you if possible to just use context directly without this.context since the only usage is in the constructor and it's a needless re-referencing that you have in there. Either way is fine for us, so up to you.

@chrissrogers
Copy link
Member

I see! Yes, that makes sense.

We have a couple other places where this.context is relied on, one of which is outside of the constructor, so I think any approach other than implementing contexts in preact's PureComponent would have to be treated as a patch..

If you're willing to make that request of preact, then I think that's a great idea. That would address all of these cases, and those in any other library, in the most 'correct' way. We can consider ways to patch it in react-recurly, but I'm also somewhat concerned about any other potential compatibility issues that may exist between the APIs.

@Silviu-Marian
Copy link
Author

Thanks for taking the time to look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants