Skip to content

sylvain75/bookList_Redux_intro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#From EggHead

  • State tree is redonding (can't modify)
  • Action is the representation of the change of the data
    • need to have type property (can't be undefined)
  • We can change the State tree by dispatching an Action (JS Object)
  • Component dispatch action

#App State with redux

__Component State !== Application State

Redux in charge of the application state

React provides views to display state

Application state generated by reducer function

##Folders

Folder Structure

###Reducers folder: reducers_books.js -> array containing list of object where each object contains list of books with title as key index.js ->

import { combineReducers } from 'redux';
import BooksReducer from './reducer_books';

//_book reducer added to combineReducers_
const rootReducer = combineReducers({
	//_reducer add key (books) and value of what returns (BooksReducer=array of books) to the global application state_
  books: BooksReducer
});

export default rootReducer;

###Containers folder Book_list.js depends on the state so had to be "promoted" in the container folder ####difference with components folder: import { connect } from 'react-redux'; to be able to use the connect function linking React and Redux libraries

function mapStateToProps( state ) {
  // Whatever it returned will show up as props inside of BookList
  return {
    books: state.books
  };
}

export default connect( mapStateToProps )( BookList )

in app.js make sure BookList is rendered.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published