You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an infinite loop situation where basically what's happening is this:
I have a Parent component that contains two functions, showSpinner and hideSpinner, which essentially set the Parent state to spinnerVisible: true and spinnerVisible: false, respectively.
I'm using context to pass these functions down wherever they're needed:
And then in a child template (we'll call Child for simplicity's sake):
getMeteorData(){lethandle=Meteor.subscribe('tracks');if(!handle.ready()){this.context.showSpinner(TAPi18n.__('loadingTracks'),true);}else{this.context.hideSpinner();console.log('we are ready');}return{ready: handle.ready(),tracks: Tracks.find({},{sort: {createdAt: -1}}).fetch()}},
What happens is, I get the spinner for a couple seconds while the subscription is waiting for data (I have an artificial 5-second sleep in the publication). Once it's ready, I get an infinite amount of "we are ready" messages being dumped.
The interesting thing is, if I remove this.context.hideSpinner(), I get the message just once. So apparently, when hideSpinner() is setting the Parent's state to spinnerVisible: false, it's triggering the getMeteorData method over and over. I'm guessing this might be a bug involving React's context feature, but I could be wrong.
Any help on this would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
I've run into an infinite loop situation where basically what's happening is this:
I have a Parent component that contains two functions,
showSpinner
andhideSpinner
, which essentially set the Parent state tospinnerVisible: true
andspinnerVisible: false
, respectively.I'm using context to pass these functions down wherever they're needed:
Parent.jsx
And then in a child template (we'll call Child for simplicity's sake):
What happens is, I get the spinner for a couple seconds while the subscription is waiting for data (I have an artificial 5-second sleep in the publication). Once it's ready, I get an infinite amount of "we are ready" messages being dumped.
The interesting thing is, if I remove
this.context.hideSpinner()
, I get the message just once. So apparently, whenhideSpinner()
is setting the Parent's state tospinnerVisible: false
, it's triggering thegetMeteorData
method over and over. I'm guessing this might be a bug involving React's context feature, but I could be wrong.Any help on this would be greatly appreciated!
The text was updated successfully, but these errors were encountered: