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

[Feature]: Does it support the React v18 hook useSyncExternalStore? (useNetwork) #490

Closed
1 task done
ssi02014 opened this issue Jun 2, 2024 · 0 comments
Closed
1 task done

Comments

@ssi02014
Copy link
Contributor

ssi02014 commented Jun 2, 2024

Package Scope

  • Add to an existing package

Package name: @toss/react

Overview

As the title suggests, I am curious if slash supports the useSyncExternalStore!

Currently, I am considering a useNetwork hook that uses useSyncExternalStore to subscribe to the browser's network connection status and handle sudden network disconnections while the user is using the application.

const { isOnline } = useNetwork({
  onlineCallback: () => {
    // ...
  },
  offlineCallback: () => {
    navigate('/offline'); // It handles sudden network disconnections for the user.
  },
});

useNetwork implementation code
The above link is the implementation code for useNetwork that I am currently working on.

useNetwork Example
There is a simple example in the above document, so please feel free to check it out.

I have based it on the example from react.dev - useOnlineStatus, but have extended it by adding onlineCallback and offlineCallback functionalities.

I think it would be great if slash also provided a useNetwork hook. However, I need to know whether useSyncExternalStore is supported and hear the administrators' opinions first, so I am creating this issue.

@ssi02014 ssi02014 closed this as completed Jul 8, 2024
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

No branches or pull requests

1 participant