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

Support withCredentials in useEventSource() #229

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

Conversation

kensnyder
Copy link

If you pass an object as init the hook will call open and immediately close every render because the init object is a by-reference dependency of the useEffect. MDN currently only documents one possible option: withCredentials: boolean;.

In this PR I just handle withCredentials specially. An alternative would be to just remove init from the dependency array because changing it after creating the EventSource doesn't make sense. Another possible solution is to use JSON.stringify() outside the useEffect and JSON.parse() inside the useEffect.

@chrisidakwo
Copy link

@sergiodxa It'll be nice to have this merged or are there any issues with it?

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.

2 participants