Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Day 1
- import React from "react";
- import Map from "./Expando/Map";
- export default class Expando extends React.Component {
- handleData () {
- let elements = [];
- const _this = this;
- for (var map of this.props.maps) {
- elements.push(<Map key = { map.id } map = { map } onClick = { _this.props.updateHandler }/>);
- }
- return elements;
- }
- render () {
- const maps = this.handleData();
- return (
- <div class="expando collapsed animated">
- {maps}
- </div>
- );
- }
- }
- // Day 2 Refactored
- import React from "react";
- import Map from "./Expando/Map";
- const Expando = ({maps, updateHandler}) => {
- return (
- <div className="expando collapsed animated">
- {maps.map(m => <Map key={m.id} map={m} onClick={updateHandler} />)}
- </div>
- );
- };
- export default Expando;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement