006. react - redux framework

20
006. REDUX FRAMEWORK Presenter: Binh Quan

Upload: binh-quan-duc

Post on 20-Mar-2017

49 views

Category:

Software


7 download

TRANSCRIPT

Page 1: 006. React - Redux framework

006. REDUX FRAMEWORKPresenter: Binh Quan

Page 2: 006. React - Redux framework

ReactJS - Redux

❖ Why Redux❖ Store, Actions and Reducer❖ Redux Alternatives

Page 3: 006. React - Redux framework

ReactJS - Why Redux

❖ State management for whole system❖ One store / Multiple Reducers❖ Connecting React components❖ Dispatching events❖ Server rendering (you don’t need any special API to

manage)

Page 4: 006. React - Redux framework

ReactJS - without Redux

Page 5: 006. React - Redux framework

ReactJS - with Redux

Page 6: 006. React - Redux framework

ReactJS - without Redux vs with Redux

Page 7: 006. React - Redux framework

ReactJS - more about Redux

Read more: ★ https://css-tricks.com/learning-react-redux/★ https://blog.jumpcut.com/why-redux-why-now-32

b3f95b59b#.4drj7z90i

Page 8: 006. React - Redux framework

ReactJS - Redux terms

Terms in Redux❖ Application state

➢ State vs Stateless❖ Reducers❖ Store❖ Provider❖ Actions❖ Dispatch

Page 9: 006. React - Redux framework

ReactJS - Redux flow

Basic flow

❖ Application state

❖ Reducers❖ Store❖ Provider❖ Actions❖ Dispatch

Page 10: 006. React - Redux framework

ReactJS - Redux side effects with API middlewareSide effects

withAPI middleware❖ Application

state❖ Reducers❖ Store❖ Provider❖ Actions❖ Dispatch

Page 11: 006. React - Redux framework

ReactJS - Redux flow

More explanations: ★ https://github.com/reactjs/redux/issues/653

Page 12: 006. React - Redux framework

Reducers

The Reducer is function that takes the previous state and an action, processing previous state then return next state.

Note:

❖ Each reducer often contains initial state

❖ Next state is not that old state with modification. It’s completely a new object

New state (object) is

returned after

processing old state

Page 13: 006. React - Redux framework

Store

Store with single reducer

Page 14: 006. React - Redux framework

Store

Store with multiple reducers

Page 15: 006. React - Redux framework

Provider

Provider is top Component that used to connect Redux store and React Component

Page 16: 006. React - Redux framework

Actions

Actions are payloads of information that send data from your application to your store. They are the only source of information for the store. You send them to the store using store.dispatch().

Page 17: 006. React - Redux framework

Dispatch

Dispatch is the method of sending data from component to store for processing according to specific action.

Page 18: 006. React - Redux framework

Get application state

Page 19: 006. React - Redux framework

Bind dispatch to React Component

Page 20: 006. React - Redux framework

Now Demo