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 React context with provider/consumer to pass status #23

Open
ramyma opened this issue Jan 14, 2019 · 2 comments
Open

Use React context with provider/consumer to pass status #23

ramyma opened this issue Jan 14, 2019 · 2 comments
Labels
v3 possible v3.0.0 features

Comments

@ramyma
Copy link

ramyma commented Jan 14, 2019

I am using the Online and Offline components in a couple of places within my application and noticed that the application is hitting the polling url every 5 seconds about 3 times, which shows that each Online/Offline component checks separately for the connection's status.

I propose creating a Provider which could be used to wrap the application's root component and just use a Consumer anywhere where the connection status is needed.

It would look something like:

<Provider {...config}>
  <App />
</Provider>
<Consumer>
  {({ online }) => (
    <div>
      {`${online}`}
    </div>
  )}
</Consumer>

I can create a PR to implement it if it's OK.

What do you think ?

@chrisbolin
Copy link
Collaborator

I love the idea of having one provider! Definitely put up the PR and I can take a look at it. Thank you!

@chrisbolin
Copy link
Collaborator

Hopefully something we can do in v3

@chrisbolin chrisbolin added the v3 possible v3.0.0 features label Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 possible v3.0.0 features
Projects
None yet
Development

No branches or pull requests

2 participants