Skip to content

Support withCredentials in useEventSource()#229

Open
kensnyder wants to merge 1 commit intosergiodxa:mainfrom
kensnyder:patch-1
Open

Support withCredentials in useEventSource()#229
kensnyder wants to merge 1 commit intosergiodxa:mainfrom
kensnyder:patch-1

Conversation

@kensnyder
Copy link
Copy Markdown

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
Copy Markdown

@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