You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no need in Nuclear to call observe() to get the updated state into your component so that it re-renders.
Instead, you just define a getDataBindings(0 function for the component, and whenever the data changes, Nuclear will call setState() for you, thereby causing React to re-render your component.
Remove the observe call (you don't need componentDidMount() here either) and also remove the this.state = {} part from your constructor.
Then, add something like this to your React class:
@mindjuice Thank you for your answer. Sadly it still does not work. I tried rereading the NuclearJS docs, but I don't seem to get the hang of it.
My code now is:
export default class FavoriteList extends React.Component {
constructor(){
super();
this._getDataBindings = this._getDataBindings.bind(this);
this.state={
}
}
_getDataBindings(){
return {
favoritesList: favoriteListGetters.favoriteBlocks
};
}
render() {
//TODO: Render the items added to the list
return(
<div>
<List subheader="Favo's" subheaderStyle={{ fontSize: 18}}>
{this.state.favoritesList}
</List>
</div>
);
}
}
Could you tell me where I go wrong, we could also do this over PM in Gitter if you would prefer that.
MinThaMie
changed the title
Observe is only called once instead of everytime something changes in the store
[QUESTION] Observe is only called once instead of everytime something changes in the store
Sep 8, 2015
The goal is that some items can become favorite and are then rendered in a special list.
But my code does not work cause the observer just works once. Have this problem more often so somehow my implementation of observe isn't correct.
First the user clicks on a listitem with calls upon an action:
This reaches the store:
Getter:
and then the observer is called:
The text was updated successfully, but these errors were encountered: