-
Book Overview & Buying
-
Table Of Contents
Getting Started with React
By :
In each of the React components (readingList and bookList), getInitialState() is initialized with the store public method getReadingList() and getLibrary(), respectively.
Various methods are executed at precise points in a component's lifecycle.
componentWillMount() is a React lifecycle method. It is invoked once, both on the client and server, immediately before the initial rendering occurs. If you call setState within this method, render() will see the updated state and will be executed only once despite change in the state:
componentWillMount:function(){
AppStore.addChangeListener(this._onChange)
},
_onChange: function(){
this.setState(readingItems())
}Thus, componentWillMount() is listening to the addChangeListener (defined in the AppStore store). If the _onChange parameter is passed, then the current object (_this) is updated (setState) with the new/updated data/payload (readingItems).
In order to remove the items from the reading list, the event listener...
Change the font size
Change margin width
Change background colour