Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

*mobxAutorun makes the whole component not being rendered

Tags:

angular

mobx

I must be missing something obvious. If I add *mobxAutorun on the top of tags.component.html, the whole component is not rendered. If I remove it, it is rendered on the bottom of the page, but the the code reflecting to the commonStore.isLoadingTags is not processed correctly.

I followed everything at mobx-angular, I event updated one of the samples to Angular 4+, but my simple change in the Realworld Angular 4+/Mobx repository is still not working. Thanks for your suggestions!

like image 353
davidpodhola Avatar asked Nov 16 '25 06:11

davidpodhola


1 Answers

TLDR: Don't forget to import the MobxAngularModule so it is accessible in the module you're using the *mobxAutorun directive.

@NgModule({
    ...
    imports: [
        ...
        MobxAngularModule
    ]
})

I ran into the same issue today in my own code, not in the mentioned sample. The answer is specific for the provided sample. If anyone runs into this issue, you can generally say that the MobxAngularModule needs to be available in the module/component you're using *mobxAutorun. It does not matter if you're using some kind of SharedModule in which you re-export it or you just declare the import directly in the module you're using the directive.

like image 70
kvetis Avatar answered Nov 18 '25 21:11

kvetis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!