Closed gsouf closed 4 years ago
I found that doc.data.someField is always undefined.
Have you wrapped your component with observer
?
In the doc I couldn't find any example of how to fetch a document. I
Documents and collections are typically fetched automatically. This happens magically when you access data from the render function in your React Component; and your component is wrapped with observer
.
You can also choose to use manual fetching. In that case you can indeed call fetch
yourself.
In the readme the document is instancied in a variable but never used.
Could you show me code sample that is wrong?
Which doc
Hi @IjzerenHein the example I mentioned is the one from the readme.
SoI found that indeed it's working properly without fetch when we use an observer.
I got fooled because usage the fetch method causesdocument.isLoading
to become true, but autofetching does not. Also autofetching without the obersver causes document.data.name
to be undefined in my render method and thus document.data.something
was throwing errors
Yes, nothing happens when you don't have your component wrapped with observer
.
Tried to work with the document that way:
I found that
doc.data.someField
is always undefined.Alternatively I tried that:
Now
doc.data.someField
has the expected value.In the doc I couldn't find any example of how to fetch a document. In the readme the document is instancied in a variable but never used.