Become a member
Sign in
Adam Klein
Adam Klein

Adam Klein

50 Following
80 Followers
  • Profile

  • Claps

  • Responses

Latest

Adam Klein
Adam Klein
Feb 27 · 1 min read

Redux Bad Practices — 6 part series

I wrote 6 short articles about better ways to write your Redux code. Hope you find it useful!

https://medium.com/@adamklein_66511/redux-bad-practices-1-lists-as-arrays-9115ba87b0ce

19

Adam Klein
Adam Klein
Feb 27 · 1 min read

Redux Bad Practices #6: Mix UI State with Model Data

In a Redux store, you may have both data from the server, together with the UI-related state. For example, you can have a list of products from the server, and save which one of those the user has selected using a checkbox.

Adam Klein
Adam Klein
Feb 27 · 2 min read

Redux Bad Practices #5: New Objects On The Fly

Consider the following code:

mapStateToProps = (state) => ({
currentUser: {
id: state.currentUserId, role: state.currentRole
}
})

1

Adam Klein
Adam Klein
Feb 27 · 1 min read

Redux Bad Practices #4: Duplicate State

Let’s say you need to display a filtered list of products.

One approach would be to save the filtered list on each filter change in a component’s state or in a different key in a Redux store:

1

Adam Klein
Adam Klein
Feb 27 · 1 min read

Redux Bad Practices #3: Nested State

Complex applications usually deal with data structures that have associations, e.g. posts that have comments.

You might save the data nested in the state:

posts:
id: 1
title: 'Better Redux'
comments:
id…

1