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

How is startPolling and stopPolling supposed to work? #5

Open
K3CK opened this issue May 23, 2019 · 5 comments
Open

How is startPolling and stopPolling supposed to work? #5

K3CK opened this issue May 23, 2019 · 5 comments
Labels
question Further information is requested

Comments

@K3CK
Copy link

K3CK commented May 23, 2019

First of all: great work!

But I don't understand how those two functions are supposed to work. Calling them in the render property like so

render={({ startPolling, stopPolling, isPolling }) => { if (this.state.view === 'results') { stopPolling(); } }}

leads to an TypeError:

TypeError: Cannot read property '_ismounted' of undefined

What I'd like to to is to stop polling for a certain state in the application and re-start it after another event occurs.

@vivek12345
Copy link
Owner

@K3CK Thank you for the kind words and sorry to see it not working as expected.
Can you try with the latest release v1.0.5?
That should fix your issue and startPolling, stopPolling should work as expected.

Let me know if you still face any issues.

@K3CK
Copy link
Author

K3CK commented May 23, 2019

Thanks for your fast response. But unfortunately it throws now a different error:

Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.
And
Uncaught Invariant Violation: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

@vivek12345
Copy link
Owner

can you create a codesandbox link for me to check?

@fjacobs
Copy link

fjacobs commented Sep 20, 2019

I have a stupid question: I was wondering how do I get the body of the response in your example:

if(isPolling) {
                            return (
                                <div> Returned json: ? </div>
                            );
                        } else {
                            return (
                                <div> Hello I stopped polling</div>
                            );
                        }

@vivek12345
Copy link
Owner

vivek12345 commented Sep 20, 2019

@fjacobs the response is always returned to the onSuccess handler so you can use that and then set your own local component state. For example in a twitter feed example you can have a local component with this.state = { feeds: [] } and on every polling success you might append the new tweets to this feed.

I hope that answers your question.

@vivek12345 vivek12345 added the question Further information is requested label Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants