Closed tylerolechnowicz closed 5 years ago
The problem lies in FlatList which is not reactive (does not have observer). Adding @observer
to ListItem
should solve it. Unless you have it there already and then it's some other issue I don't see here.
The problem lies in FlatList which is not reactive (does not have observer). Adding
@observer
toListItem
should solve it. Unless you have it there already and then it's some other issue I don't see here.
@FredyC
I get a red error line when trying to add @observer
to ListItem
See also: https://mobx.js.org/best/pitfalls.html#rendering-listviews-in-react-native
@mweststrate Thanks for your reply. I am not using an observable array in this case. The @observable
that I want to cause a re-render is a boolean
@tylerolechnowicz Um, obviously ... You need to make a separate component with ListItem which will have the observer.
(@)observer is about components definitions, not about JSX (which just calls components)
So renderItem = observer(({ item, index }) => ....
should do the trick.
... Or use an <Observer>
section inside that inline component
@mweststrate Wrapping the component in
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.
Hello,
I have been reading the documentation and searching around and for the life of me I cannot figure out why my component is not re-rendering when the value of my observable changes...
When I click on the checkbox that is created in my
renderItem()
function, it callsonHandleLanguageChange()
which does update myselectedLanguage
observable, but the actual checkbox is not reflecting the change. I would appreciate any assistance.Thanks!