在React-Redux中过滤数据

时间:2017-05-29 13:37:20

标签: reactjs redux react-redux

在我的React-Redux应用程序中我的    const {products,location,dispatch} = this.props 在json As中给我product列表输出

`{"products":[{"id":1,"slug":"ruby-on-rails-tote","name":"Ruby on Rails Tote","description":"Eius accusantium eos aperiam voluptas impedit. Iste necessitatibus vel repellat nihil. Quisquam at corrupti voluptas et quos tenetur deleniti sit. Laboriosam blanditiis mollitia ducimus autem ea.","master":{"id":1,"is_master":true,"name":"Ruby on Rails Tote","options_text":"","sku":"ROR-00011","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":1,"variant_id":1,"amount":"15.99","currency":"USD"},{"id":2,"variant_id":1,"amount":"14.0","currency":"EUR"}],"images":[{"id":21,"viewable_type":"Spree::Variant","viewable_id":1,"url":"/spree/images/attachments/000/000/021/product/ror_tote.jpeg?1489147064"},{"id":22,"viewable_type":"Spree::Variant","viewable_id":1,"url":"/spree/images/attachments/000/000/022/product/ror_tote_back.jpeg?1489147064"}]},"images":[{"id":21,"viewable_type":"Spree::Variant","viewable_id":1,"url":"/spree/images/attachments/000/000/021/product/ror_tote.jpeg?1489147064"},{"id":22,"viewable_type":"Spree::Variant","viewable_id":1,"url":"/spree/images/attachments/000/000/022/product/ror_tote_back.jpeg?1489147064"}],"variants":[],"product_properties":[{"id":25,"value":"Tote","name":"Type"},{"id":26,"value":"15\" x 18\" x 6\"","name":"Size"},{"id":27,"value":"Canvas","name":"Material"}],"taxons":[{"id":3,"name":"Bags"},{"id":11,"name":"Rails"},{"id":1,"name":"Brands"}]},{"id":2,"slug":"ruby-on-rails-bag","name":"Ruby on Rails Bag","description":"Vel nihil dolorem inventore tenetur. Alias omnis molestias rerum voluptatem. Incidunt fugiat quae aut excepturi dolorem sint. Iste sequi illo quas commodi adipisci necessitatibus neque facilis. Voluptas dolorem quidem eius quaerat molestias voluptatibus officia.","master":{"id":2,"is_master":true,"name":"Ruby on Rails Bag","options_text":"","sku":"ROR-00012","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":3,"variant_id":2,"amount":"22.99","currency":"USD"},{"id":4,"variant_id":2,"amount":"19.0","currency":"EUR"}],"images":[{"id":23,"viewable_type":"Spree::Variant","viewable_id":2,"url":"/spree/images/attachments/000/000/023/product/ror_bag.jpeg?1489147065"}]},"images":[{"id":23,"viewable_type":"Spree::Variant","viewable_id":2,"url":"/spree/images/attachments/000/000/023/product/ror_bag.jpeg?1489147065"}],"variants":[],"product_properties":[{"id":28,"value":"Messenger","name":"Type"},{"id":29,"value":"14 1/2\" x 12\" x 5\"","name":"Size"},{"id":30,"value":"600 Denier Polyester","name":"Material"}],"taxons":[{"id":3,"name":"Bags"},{"id":11,"name":"Rails"}]},{"id":3,"slug":"ruby-on-rails-baseball-jersey","name":"Ruby on Rails Baseball Jersey","description":"Nobis nemo esse doloremque perferendis sed sequi. Nisi quas aliquid optio provident. Suscipit dolorem rem hic distinctio sit deserunt sapiente. Beatae at eum voluptatem impedit quasi vero autem. Sed magni qui eligendi animi sed.","master":{"id":3,"is_master":true,"name":"Ruby on Rails Baseball Jersey","options_text":"","sku":"ROR-001","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":5,"variant_id":3,"amount":"19.99","currency":"USD"},{"id":6,"variant_id":3,"amount":"16.0","currency":"EUR"}],"images":[{"id":24,"viewable_type":"Spree::Variant","viewable_id":3,"url":"/spree/images/attachments/000/000/024/product/ror_baseball.jpeg?1489147065"},{"id":25,"viewable_type":"Spree::Variant","viewable_id":3,"url":"/spree/images/attachments/000/000/025/product/ror_baseball_back.jpeg?1489147065"}]},"images":[{"id":24,"viewable_type":"Spree::Variant","viewable_id":3,"url":"/spree/images/attachments/000/000/024/product/ror_baseball.jpeg?1489147065"},{"id":25,"viewable_type":"Spree::Variant","viewable_id":3,"url":"/spree/images/attachments/000/000/025/product/ror_baseball_back.jpeg?1489147065"}],"variants":[{"id":17,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: S, Color: Red","sku":"ROR-00001","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":33,"variant_id":17,"amount":"19.99","currency":"USD"}],"images":[{"id":1,"viewable_type":"Spree::Variant","viewable_id":17,"url":"/spree/images/attachments/000/000/001/product/ror_baseball_jersey_red.png?1489147058"},{"id":2,"viewable_type":"Spree::Variant","viewable_id":17,"url":"/spree/images/attachments/000/000/002/product/ror_baseball_jersey_back_red.png?1489147058"}]},{"id":18,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: S, Color: Blue","sku":"ROR-00002","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":34,"variant_id":18,"amount":"19.99","currency":"USD"}],"images":[{"id":3,"viewable_type":"Spree::Variant","viewable_id":18,"url":"/spree/images/attachments/000/000/003/product/ror_baseball_jersey_blue.png?1489147059"},{"id":4,"viewable_type":"Spree::Variant","viewable_id":18,"url":"/spree/images/attachments/000/000/004/product/ror_baseball_jersey_back_blue.png?1489147059"}]},{"id":19,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: S, Color: Green","sku":"ROR-00003","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":35,"variant_id":19,"amount":"19.99","currency":"USD"}],"images":[{"id":5,"viewable_type":"Spree::Variant","viewable_id":19,"url":"/spree/images/attachments/000/000/005/product/ror_baseball_jersey_green.png?1489147059"},{"id":6,"viewable_type":"Spree::Variant","viewable_id":19,"url":"/spree/images/attachments/000/000/006/product/ror_baseball_jersey_back_green.png?1489147060"}]},{"id":20,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: M, Color: Red","sku":"ROR-00004","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":36,"variant_id":20,"amount":"19.99","currency":"USD"}],"images":[{"id":7,"viewable_type":"Spree::Variant","viewable_id":20,"url":"/spree/images/attachments/000/000/007/product/ror_baseball_jersey_red.png?1489147060"},{"id":8,"viewable_type":"Spree::Variant","viewable_id":20,"url":"/spree/images/attachments/000/000/008/product/ror_baseball_jersey_back_red.png?1489147060"}]},{"id":21,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: M, Color: Blue","sku":"ROR-00005","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":37,"variant_id":21,"amount":"19.99","currency":"USD"}],"images":[{"id":9,"viewable_type":"Spree::Variant","viewable_id":21,"url":"/spree/images/attachments/000/000/009/product/ror_baseball_jersey_blue.png?1489147061"},{"id":10,"viewable_type":"Spree::Variant","viewable_id":21,"url":"/spree/images/attachments/000/000/010/product/ror_baseball_jersey_back_blue.png?1489147061"}]},{"id":22,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: M, Color: Green","sku":"ROR-00006","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":38,"variant_id":22,"amount":"19.99","currency":"USD"}],"images":[{"id":11,"viewable_type":"Spree::Variant","viewable_id":22,"url":"/spree/images/attachments/000/000/011/product/ror_baseball_jersey_green.png?1489147061"},{"id":12,"viewable_type":"Spree::Variant","viewable_id":22,"url":"/spree/images/attachments/000/000/012/product/ror_baseball_jersey_back_green.png?1489147061"}]},{"id":23,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: L, Color: Red","sku":"ROR-00007","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":39,"variant_id":23,"amount":"19.99","currency":"USD"}],"images":[{"id":13,"viewable_type":"Spree::Variant","viewable_id":23,"url":"/spree/images/attachments/000/000/013/product/ror_baseball_jersey_red.png?1489147062"},{"id":14,"viewable_type":"Spree::Variant","viewable_id":23,"url":"/spree/images/attachments/000/000/014/product/ror_baseball_jersey_back_red.png?1489147062"}]},{"id":24,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: L, Color: Blue","sku":"ROR-00008","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":40,"variant_id":24,"amount":"19.99","currency":"USD"}],"images":[{"id":15,"viewable_type":"Spree::Variant","viewable_id":24,"url":"/spree/images/attachments/000/000/015/product/ror_baseball_jersey_blue.png?1489147062"},{"id":16,"viewable_type":"Spree::Variant","viewable_id":24,"url":"/spree/images/attachments/000/000/016/product/ror_baseball_jersey_back_blue.png?1489147063"}]},{"id":25,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: L, Color: Green","sku":"ROR-00009","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":41,"variant_id":25,"amount":"19.99","currency":"USD"}],"images":[{"id":17,"viewable_type":"Spree::Variant","viewable_id":25,"url":"/spree/images/attachments/000/000/017/product/ror_baseball_jersey_green.png?1489147063"},{"id":18,"viewable_type":"Spree::Variant","viewable_id":25,"url":"/spree/images/attachments/000/000/018/product/ror_baseball_jersey_back_green.png?1489147063"}]},{"id":26,"is_master":false,"name":"Ruby on Rails Baseball Jersey","options_text":"Size: XL, Color: Green","sku":"ROR-00010","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":42,"variant_id":26,"amount":"19.99","currency":"USD"}],"images":[{"id":19,"viewable_type":"Spree::Variant","viewable_id":26,"url":"/spree/images/attachments/000/000/019/product/ror_baseball_jersey_green.png?1489147063"},{"id":20,"viewable_type":"Spree::Variant","viewable_id":26,"url":"/spree/images/attachments/000/000/020/product/ror_baseball_jersey_back_green.png?1489147064"}]}],"product_properties":[{"id":1,"value":"Wilson","name":"Manufacturer"},{"id":2,"value":"Wannabe Sports","name":"Brand"},{"id":3,"value":"JK1002","name":"Model"},{"id":4,"value":"Baseball Jersey","name":"Shirt Type"},{"id":5,"value":"Long","name":"Sleeve Type"},{"id":6,"value":"100% cotton","name":"Made from"},{"id":7,"value":"Loose","name":"Fit"},{"id":8,"value":"Men's","name":"Gender"}],"taxons":[{"id":7,"name":"T-Shirts"},{"id":11,"name":"Rails"}]},{"id":4,"slug":"ruby-on-rails-jr-spaghetti","name":"Ruby on Rails Jr. Spaghetti","description":"Velit accusamus quas sequi repudiandae inventore. Aut quo dolorum nihil et sit. Assumenda dolore est et repellat ut. Distinctio atque sunt reiciendis ad adipisci dolores ea. Voluptatem ullam nobis et doloribus et maxime.","master":{"id":4,"is_master":true,"name":"Ruby on Rails Jr. Spaghetti","options_text":"","sku":"ROR-00013","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":7,"variant_id":4,"amount":"19.99","currency":"USD"},{"id":8,"variant_id":4,"amount":"16.0","currency":"EUR"}],"images":[{"id":26,"viewable_type":"Spree::Variant","viewable_id":4,"url":"/spree/images/attachments/000/000/026/product/ror_jr_spaghetti.jpeg?1489147066"}]},"images":[{"id":26,"viewable_type":"Spree::Variant","viewable_id":4,"url":"/spree/images/attachments/000/000/026/product/ror_jr_spaghetti.jpeg?1489147066"}],"variants":[],"product_properties":[{"id":9,"value":"Jerseys","name":"Manufacturer"},{"id":10,"value":"Resiliance","name":"Brand"},{"id":11,"value":"TL174","name":"Model"},{"id":12,"value":"Jr. Spaghetti T","name":"Shirt Type"},{"id":13,"value":"None","name":"Sleeve Type"},{"id":14,"value":"90% Cotton, 10% Nylon","name":"Made from"},{"id":15,"value":"Form","name":"Fit"},{"id":16,"value":"Women's","name":"Gender"}],"taxons":[{"id":6,"name":"Shirts"},{"id":11,"name":"Rails"}]},{"id":5,"slug":"ruby-on-rails-ringer-t-shirt","name":"Ruby on Rails Ringer T-Shirt","description":"Quod amet tempora modi voluptas corporis qui aliquam molestiae. Maxime molestiae aperiam corrupti nihil repellendus. Quae rerum nobis ad commodi. Aspernatur quo eos aut fuga.","master":{"id":5,"is_master":true,"name":"Ruby on Rails Ringer T-Shirt","options_text":"","sku":"ROR-00015","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":9,"variant_id":5,"amount":"19.99","currency":"USD"},{"id":10,"variant_id":5,"amount":"16.0","currency":"EUR"}],"images":[{"id":29,"viewable_type":"Spree::Variant","viewable_id":5,"url":"/spree/images/attachments/000/000/029/product/ror_ringer.jpeg?1489147067"},{"id":30,"viewable_type":"Spree::Variant","viewable_id":5,"url":"/spree/images/attachments/000/000/030/product/ror_ringer_back.jpeg?1489147067"}]},"images":[{"id":29,"viewable_type":"Spree::Variant","viewable_id":5,"url":"/spree/images/attachments/000/000/029/product/ror_ringer.jpeg?1489147067"},{"id":30,"viewable_type":"Spree::Variant","viewable_id":5,"url":"/spree/images/attachments/000/000/030/product/ror_ringer_back.jpeg?1489147067"}],"variants":[],"product_properties":[{"id":17,"value":"Jerseys","name":"Manufacturer"},{"id":18,"value":"Conditioned","name":"Brand"},{"id":19,"value":"TL9002","name":"Model"},{"id":20,"value":"Ringer T","name":"Shirt Type"},{"id":21,"value":"Short","name":"Sleeve Type"},{"id":22,"value":"100% Vellum","name":"Made from"},{"id":23,"value":"Loose","name":"Fit"},{"id":24,"value":"Men's","name":"Gender"}],"taxons":[{"id":7,"name":"T-Shirts"},{"id":11,"name":"Rails"}]},{"id":6,"slug":"ruby-baseball-jersey","name":"Ruby Baseball Jersey","description":"Itaque ea delectus voluptas accusamus sequi magni voluptates aut. Mollitia quisquam eum vitae omnis eos. Consequatur eligendi ut id temporibus sint esse.","master":{"id":6,"is_master":true,"name":"Ruby Baseball Jersey","options_text":"","sku":"RUB-00001","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":11,"variant_id":6,"amount":"19.99","currency":"USD"},{"id":12,"variant_id":6,"amount":"16.0","currency":"EUR"}],"images":[{"id":34,"viewable_type":"Spree::Variant","viewable_id":6,"url":"/spree/images/attachments/000/000/034/product/ruby_baseball.png?1489147069"}]},"images":[{"id":34,"viewable_type":"Spree::Variant","viewable_id":6,"url":"/spree/images/attachments/000/000/034/product/ruby_baseball.png?1489147069"}],"variants":[],"product_properties":[],"taxons":[{"id":7,"name":"T-Shirts"},{"id":8,"name":"Ruby"}]},{"id":7,"slug":"apache-baseball-jersey","name":"Apache Baseball Jersey","description":"Aut suscipit voluptatem repellendus voluptatem. Possimus culpa est ex harum molestias similique. Consectetur quidem at nemo aut. Aliquam facere nostrum quo quia. Corporis dolorum repellendus mollitia nihil.","master":{"id":7,"is_master":true,"name":"Apache Baseball Jersey","options_text":"","sku":"APC-00001","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":false,"prices":[{"id":13,"variant_id":7,"amount":"19.99","currency":"USD"},{"id":14,"variant_id":7,"amount":"16.0","currency":"EUR"}],"images":[{"id":33,"viewable_type":"Spree::Variant","viewable_id":7,"url":"/spree/images/attachments/000/000/033/product/apache_baseball.png?1489147068"}]},"images":[{"id":33,"viewable_type":"Spree::Variant","viewable_id":7,"url":"/spree/images/attachments/000/000/033/product/apache_baseball.png?1489147068"}],"variants":[],"product_properties":[],"taxons":[{"id":7,"name":"T-Shirts"},{"id":9,"name":"Apache"}]},{"id":8,"slug":"spree-baseball-jersey","name":"Spree Baseball Jersey","description":"Quam molestiae voluptatem autem sequi. Eum soluta porro nam ut aliquid non nemo eum. Sit nihil fuga reprehenderit itaque corporis enim assumenda numquam.","master":{"id":8,"is_master":true,"name":"Spree Baseball Jersey","options_text":"","sku":"SPR-00001","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":15,"variant_id":8,"amount":"19.99","currency":"USD"},{"id":16,"variant_id":8,"amount":"16.0","currency":"EUR"}],"images":[{"id":41,"viewable_type":"Spree::Variant","viewable_id":8,"url":"/spree/images/attachments/000/000/041/product/spree_jersey.jpeg?1489147071"},{"id":42,"viewable_type":"Spree::Variant","viewable_id":8,"url":"/spree/images/attachments/000/000/042/product/spree_jersey_back.jpeg?1489147071"}]},"images":[{"id":41,"viewable_type":"Spree::Variant","viewable_id":8,"url":"/spree/images/attachments/000/000/041/product/spree_jersey.jpeg?1489147071"},{"id":42,"viewable_type":"Spree::Variant","viewable_id":8,"url":"/spree/images/attachments/000/000/042/product/spree_jersey_back.jpeg?1489147071"}],"variants":[],"product_properties":[{"id":43,"value":"Wilson","name":"Manufacturer"},{"id":44,"value":"Wannabe Sports","name":"Brand"},{"id":45,"value":"JK1002","name":"Model"},{"id":46,"value":"Baseball Jersey","name":"Shirt Type"},{"id":47,"value":"Long","name":"Sleeve Type"},{"id":48,"value":"100% cotton","name":"Made from"},{"id":49,"value":"Loose","name":"Fit"},{"id":50,"value":"Men's","name":"Gender"}],"taxons":[{"id":7,"name":"T-Shirts"},{"id":10,"name":"Spree"}]},{"id":9,"slug":"spree-jr-spaghetti","name":"Spree Jr. Spaghetti","description":"Non eum ipsum autem inventore iste commodi velit nesciunt. Vel consectetur itaque quia quis blanditiis in placeat. Veniam suscipit vel natus deleniti ullam. Deserunt nihil eius quos qui voluptatem quam.","master":{"id":9,"is_master":true,"name":"Spree Jr. Spaghetti","options_text":"","sku":"SPR-00013","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":17,"variant_id":9,"amount":"19.99","currency":"USD"},{"id":18,"variant_id":9,"amount":"16.0","currency":"EUR"}],"images":[{"id":40,"viewable_type":"Spree::Variant","viewable_id":9,"url":"/spree/images/attachments/000/000/040/product/spree_spaghetti.jpeg?1489147071"}]},"images":[{"id":40,"viewable_type":"Spree::Variant","viewable_id":9,"url":"/spree/images/attachments/000/000/040/product/spree_spaghetti.jpeg?1489147071"}],"variants":[],"product_properties":[{"id":51,"value":"Jerseys","name":"Manufacturer"},{"id":52,"value":"Resiliance","name":"Brand"},{"id":53,"value":"TL174","name":"Model"},{"id":54,"value":"Jr. Spaghetti T","name":"Shirt Type"},{"id":55,"value":"None","name":"Sleeve Type"},{"id":56,"value":"90% Cotton, 10% Nylon","name":"Made from"},{"id":57,"value":"Form","name":"Fit"},{"id":58,"value":"Women's","name":"Gender"}],"taxons":[{"id":6,"name":"Shirts"},{"id":10,"name":"Spree"}]},{"id":10,"slug":"spree-ringer-t-shirt","name":"Spree Ringer T-Shirt","description":"Fuga hic mollitia blanditiis quas et ipsam possimus voluptatem. Aperiam nostrum voluptatibus eos magni ut accusamus voluptas et. Animi rerum soluta rem ut optio quasi iusto tempora. Excepturi saepe esse voluptas id et ullam voluptatum numquam.","master":{"id":10,"is_master":true,"name":"Spree Ringer T-Shirt","options_text":"","sku":"SPR-00015","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":19,"variant_id":10,"amount":"19.99","currency":"USD"},{"id":20,"variant_id":10,"amount":"16.0","currency":"EUR"}],"images":[{"id":38,"viewable_type":"Spree::Variant","viewable_id":10,"url":"/spree/images/attachments/000/000/038/product/spree_ringer_t.jpeg?1489147070"},{"id":39,"viewable_type":"Spree::Variant","viewable_id":10,"url":"/spree/images/attachments/000/000/039/product/spree_ringer_t_back.jpeg?1489147070"}]},"images":[{"id":38,"viewable_type":"Spree::Variant","viewable_id":10,"url":"/spree/images/attachments/000/000/038/product/spree_ringer_t.jpeg?1489147070"},{"id":39,"viewable_type":"Spree::Variant","viewable_id":10,"url":"/spree/images/attachments/000/000/039/product/spree_ringer_t_back.jpeg?1489147070"}],"variants":[],"product_properties":[{"id":59,"value":"Jerseys","name":"Manufacturer"},{"id":60,"value":"Conditioned","name":"Brand"},{"id":61,"value":"TL9002","name":"Model"},{"id":62,"value":"Ringer T","name":"Shirt Type"},{"id":63,"value":"Short","name":"Sleeve Type"},{"id":64,"value":"100% Vellum","name":"Made from"},{"id":65,"value":"Loose","name":"Fit"},{"id":66,"value":"Men's","name":"Gender"}],"taxons":[{"id":7,"name":"T-Shirts"},{"id":10,"name":"Spree"}]},{"id":11,"slug":"spree-tote","name":"Spree Tote","description":"Ut et quidem assumenda aliquam unde consequuntur harum. Assumenda ea id animi quo corrupti. Quam velit nam illum architecto vel est ratione.","master":{"id":11,"is_master":true,"name":"Spree Tote","options_text":"","sku":"SPR-00011","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":21,"variant_id":11,"amount":"15.99","currency":"USD"},{"id":22,"variant_id":11,"amount":"14.0","currency":"EUR"}],"images":[{"id":36,"viewable_type":"Spree::Variant","viewable_id":11,"url":"/spree/images/attachments/000/000/036/product/spree_tote_front.jpeg?1489147070"},{"id":37,"viewable_type":"Spree::Variant","viewable_id":11,"url":"/spree/images/attachments/000/000/037/product/spree_tote_back.jpeg?1489147070"}]},"images":[{"id":36,"viewable_type":"Spree::Variant","viewable_id":11,"url":"/spree/images/attachments/000/000/036/product/spree_tote_front.jpeg?1489147070"},{"id":37,"viewable_type":"Spree::Variant","viewable_id":11,"url":"/spree/images/attachments/000/000/037/product/spree_tote_back.jpeg?1489147070"}],"variants":[],"product_properties":[{"id":39,"value":"Tote","name":"Type"},{"id":40,"value":"15\" x 18\" x 6\"","name":"Size"}],"taxons":[{"id":3,"name":"Bags"},{"id":10,"name":"Spree"}]},{"id":12,"slug":"spree-bag","name":"Spree Bag","description":"Non eum assumenda nihil consequuntur aspernatur est qui vitae. Soluta ipsum quis repudiandae est eos. Repellendus temporibus quia quo saepe minus quae.","master":{"id":12,"is_master":true,"name":"Spree Bag","options_text":"","sku":"SPR-00012","weight":"0.0","height":null,"width":null,"depth":null,"backorderable":true,"prices":[{"id":23,"variant_id":12,"amount":"22.99","currency":"USD"},{"id":24,"variant_id":12,"amount":"19.0","currency":"EUR"}],"images":[{"id":35,"viewable_type":"Spree::Variant","viewable_id":12,"url":"/spree/images/attachments/000/000/035/product/spree_bag.jpeg?1489147069"}]},"images":[{"id":35,"viewable_type":"Spree::Variant","viewable_id":12,"url":"/spree/images/attachments/000/000/035/product/spree_bag.jpeg?1489147069"}],"variants":[],"product_properties":[{"id":41,"value":"Messenger","name":"Type"},{"id":42,"value":"14 1/2\" x 12\" x 5\"","name":"Size"}],"taxons":[{"id":3,"name":"Bags"},{"id":10,"name":"Spree"}]}],"meta":{"current_page":1,"next_page":2,"prev_page":null,"total_pages":2,"total_count":22}}`

我想根据taxons进行过滤,即只有具有分类名clothing的产品必须可见

我如何在reducer

中过滤此内容

我的减速机

export function products(state = initialState, action) {
  switch (action.type) {
   case FETCH_PRODUCTS_REQUEST:
    return Object.assign({}, state, {
    isFetching: true,
    isFetched: false
  })
case FETCH_PRODUCTS_SUCCESS:
  return Object.assign({}, state, action.products, {
    isFetching: false,
    isFetched: true
  })
  case CLEAR_PRODUCTS:
   return initialState
 default:
   return state
  }
}

任何人都可以帮助我

1 个答案:

答案 0 :(得分:0)

您不应该在redux状态下过滤数据。您应该在mapStateToProps()内部或在React组件内部进行过滤。这允许您的redux状态成为事实的来源,并在数据接近数据UI边界时处理过滤。