Hello everyone,
I have two react components:
export default class Viewer extends TrackerReact(React.Component)
export default class EpubViewer extends TrackerReact(React.Component)
In the render method of the component Viewer I check if it is ready and if it is true I return the component EpubViwer
getEbook() {
console.log(“getEbook”, this.state.subscription.ebook.ready());
if (this.state.subscription.ebook.ready()) {
if (this.state.subscription.ebook.query().count()) {
return this.state.subscription.ebook.query().fetch()[0];
} else {
return { notFound: true };
}
} else {
return null;
}
}
render(){ let ebook = this.getEbook();
if (ebook) { if (ebook.notFound) { return ( <div className="notFound"> No existe ningún ebook con el ISBN solicitado </div> ); }else{ if(ebook.format=='epub'){ return( <EpubViewer ebook={ebook} /> ) } } } else{ return ( <div className="loader"> Loading ... </div> ); } }
}
So far so good, console.log
shows two logs, the first is ready is false and the second is true, this works thanks to tracker-react.
getEbook false
getEbook true
My problem comes with the next component I return, EpubViewer, where I do exactly the same thing but with a different collection.
In this case tracker-react is not working and console.log
only shows me a false one time, and never gets to be ready. Why in the first component works and in the second not if I’m doing the same? Thank you. A greeting.