Tudip Technologies provides no endorsement and makes no representations as to accuracy, reliability, completeness, suitability or validity of any information or content on, distributed through or linked, downloaded or accessed from this site. On the other hand, Redux-Saga subscribes to the store and can trigger a saga when some action is dispatched to run or continue.įrom the above examples it is clear that react saga is a bit handy to use over react-thunk.Īll content provided on this blog is for informational purposes only. In response to an action, Thunks can never act. Although it is true that thunks and sagas are quite different in writing and reasoning, there is something bigger. You might think that syntax is the biggest difference. Here is the basic structure of Redux-thunk export const thunkName = parameters => (dispatch, getState) => ) Thunk is a function which optionaly takes some parameters and returns another function, it takes dispatch and getState functions and both of these are supplied by Redux Thunk middleware. Where as redux-saga is a library that mainly focuses on easy handling of application side effects and more efficient for execution. Thunk allows to write an action creators that return a function instead of the typical action object. Here we are going to discuss about the 2 most popular libraries redux-thunk and redux-saga.Ī thunk is a function that acts as a wrapper in which it wraps an expression to delay its evaluation. Middleware is block of code which acts as a mediater while the process of receiving a request or generating response. Now reducer is responsible what needs to be done to update the store data. The key points of interest while working with redux are “Action”, “Dispatcher” and “Reducer”.Īction is something which triggers what needs to be done from the component dispatcher collects the action that is actively triggered and pasess it to reducer. In react mostly everything is component, so if there are too many number of components, here comes the role of redux as it manages the states of all components. In React, data flows from parent component to child component in the form of props. Redux is basically a state management library for javascript applications and is mainly used with React JS and is also familiar as predictable state container.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |