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

Use context to check if script is loaded #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alucas
Copy link

@alucas alucas commented Apr 23, 2023

No description provided.

@alex-pex
Copy link
Collaborator

This one I don't see any benefit from using Context. Why did you make the change?

@alucas
Copy link
Author

alucas commented Apr 26, 2023

This one I don't see any benefit from using Context. Why did you make the change?

Hi, because when React render the PaylineWidget before the loading of the script, window.Payline is undefined and usePayline throw an error ('window.Payline is unavailable. Check if PaylineProvider is rendered within the component tree.')

@alex-pex
Copy link
Collaborator

I used a different approach to fix the problem. Context cannot be used reliably because PaylineProvider is not the only way to load payline css & js.

@alex-pex
Copy link
Collaborator

alex-pex commented Jun 13, 2023

You can try 2.0.0-beta.3. But be careful

  • usePayline is no more. It is split in two hooks: usePaylineApi and usePaylineJQuery

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

Successfully merging this pull request may close these issues.

3 participants