Advertisement
dubbie

A day difference

Dec 1st, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Day 1
  2.  
  3. import React from "react";
  4.  
  5. import Map from "./Expando/Map";
  6.  
  7. export default class Expando extends React.Component {
  8.  
  9.   handleData () {
  10.     let elements = [];
  11.     const _this = this;
  12.  
  13.     for (var map of this.props.maps) {
  14.       elements.push(<Map key = { map.id } map = { map } onClick = { _this.props.updateHandler }/>);
  15.     }
  16.  
  17.     return elements;
  18.   }
  19.  
  20.   render () {
  21.     const maps = this.handleData();
  22.  
  23.     return (
  24.       <div class="expando collapsed animated">
  25.         {maps}
  26.       </div>
  27.     );
  28.   }
  29. }
  30.  
  31. // Day 2 Refactored
  32.  
  33. import React from "react";
  34. import Map from "./Expando/Map";
  35.  
  36. const Expando = ({maps, updateHandler}) => {
  37.   return (
  38.     <div className="expando collapsed animated">
  39.       {maps.map(m => <Map key={m.id} map={m} onClick={updateHandler} />)}
  40.     </div>
  41.   );
  42. };
  43.  
  44. export default Expando;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement