Answer the question
In order to leave comments, you need to log in
Why is undefined when deriving a specific object from Mobx?
Good day, I'm trying to display information from Mobx, but when accessing a specific object - undefined, but if I access a global variable, then everything is fine. I suspect it's asynchronous, can anyone share a solution?
Link to CodeSandbox
Answer the question
In order to leave comments, you need to log in
When you access a value, it doesn't exist yet.
Changes are not tracked.
DB class - you need to add a default value:
class DB {
info = null;
...
const Episodes = observer(() => {
useEffect(() => {
...
}, [ DB.info ]);
...
return <Episodes />;
return DB.info && <Episodes />;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question