import React, { Component } from "react"; import Facade from "../Datafacade/datafacade"; import { NavLink } from 'react-router-dom'; class MapsSearch extends Component { state = { maps: [] }; componentDidMount = async () => { const maps = await Facade.getMapsBySearchCache(this.props.keyword); this.setState({ maps }); }; componentDidUpdate = async prevProps => { if (this.props.keyword !== prevProps.keyword) { const maps = await Facade.getMapsBySearchCache(this.props.keyword); this.setState({ maps }); } } render() { return (
{this.state.maps.map(e => (
Map: {e.mapname}
Stage: {e.mapstage}
))}
); } } export default MapsSearch;