Answer the question
In order to leave comments, you need to log in
Why doesn't the component re-render after the mobx state changes?
There is an Aside that should show/hide when you click a switcher
import { observer } from 'mobx-react'
import asideStore from './aside.store'
const Aside = observer(props => {
const switcherClick = () => {
asideStore.toggleAside()
}
return (
<Wrapper {...props}>
<Switcher onClick={switcherClick} />
{asideStore.show ? 'show' : 'hide'}
</Wrapper>
)
})
import { observable } from 'mobx'
class AsideStore {
@observable show
constructor() {
this.show = true
}
toggleAside() {
this.show = !this.show
}
}
export default new AsideStore()
this.show
gets changed but not re-rendered in the component. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question