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 useLayoutEffect when calling .setOptions() in ChannelProvider #1706

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

VeskeR
Copy link
Contributor

@VeskeR VeskeR commented Mar 20, 2024

This is a temporary fix for #1704. This does not fix the underlying problem of ably-js sending two ATTACH messages with the same options when we call .setOptions() in ChannelProvider.

What useLayoutEffect accomplishes is it runs before children components' useEffect hooks, thus it sets options for a channel before attachment process starts, so there will be no need for reattachment and sending a second ATTACH message.

This is a temporary fix for #1704. This does not fix the underlying
problem of ably-js sending two `ATTACH` messages with the same options
when we call `.setOptions()` in `ChannelProvider`.

What `useLayoutEffect` accomplishes is it runs before children
components' `useEffect` hooks, thus it sets options for a channel before
attachment process starts, so there will be no need for reattachment
and sending a second `ATTACH` message.
@VeskeR VeskeR merged commit c02ec56 into integration/v2 Mar 21, 2024
12 checks passed
@VeskeR VeskeR deleted the 1704/fix-react-hooks-double-attach branch March 21, 2024 14:14
@VeskeR VeskeR mentioned this pull request Mar 21, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants