1

so the list of keys I am passing to dumb components from smart components are getting bigger?

is there any other way to write this in a concise and much quicker way?

   const mapStateToProps = (state) => {
   let {keya, keyb, keyc, keyd, keye} = state.SomethingReducer.Table; 
   return {
      keya: keya, 
      keyb: keyb, 
      keyc: keyc, 
      ......
   }
  }
slopeofhope
  • 604
  • 1
  • 5
  • 17
  • 3
    Related: [One-liner to take some properties from object in ES 6](http://stackoverflow.com/q/25553910/218196) – Felix Kling Aug 25 '16 at 18:30
  • @Gothdo: The other one was first... also depends on the details. OP doesn't really provide much context. – Felix Kling Aug 25 '16 at 18:36
  • @FelixKling I mean, isn't [this](http://stackoverflow.com/q/39152331/3853934) question a duplicate of [that](http://stackoverflow.com/questions/39147759/object-destructuring-x-y-rest-for-whitelisting-properties-of-an-objec)? – Michał Perłakowski Aug 25 '16 at 18:38

1 Answers1

2

You can use ES6 feature Enhanced Object Literals.

   const mapStateToProps = (state) => {
   let {keya, keyb, keyc, keyd, keye} = state.SomethingReducer.Table; 
   return {
      keya,
      keyb, 
      keyc, 
      ......
   }
  }
Rafi Ud Daula Refat
  • 2,037
  • 16
  • 28