Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. ## Embedded React Examples
  2.  
  3. Here are two examples of ways to create an embedded React component. One with Redux and one without.
  4.  
  5. Looking at these two examples it is clear that the updaters (non-Redux) pattern is more concise and simple. It is the first thing that someone would think to do if they are embedding a React component. This begs the question "Why did the Redux folks see this pattern and then choose to add the additional features that they added?" The main features of Redux are standard actions, reducers, middleware, and connect:
  6.  
  7. ## Standard Actions
  8. - Models user/other actions as a category of things that are not coupled to the changes they cause
  9. - Allows introspection of state-which-causes-an-update
  10. - Provides consistency across Redux apps
  11.  
  12. ## Middleware
  13. - Allows separating logic over the time dimension
  14. - Provides a clear hook for things such as tracking/logging
  15.  
  16. ## Reducers
  17. - Decouples state updates from user actions
  18. - Decouples state updates from global state shape
  19.  
  20. ## Connect
  21. - Prevents prop drilling
  22. - Enables clear separation of concerns between component
  23.  
  24. After refactoring a simple embedded React component many times, you will end up with Redux. Not something Redux-ish. You will have Redux exactly. Redux solves a well-defined set of problems in a clear, human-centered way. I am willing to say this about very few bits of engineering but Redux **cannot be improved on**. Redux is 2.6kb of pure goodness.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement