import React, { Component, Fragment } from "react"; import { AdvancedSpellSearch } from "../../services/advanced-spell-search"; import { CollapsableContainer } from "../containers/collapsable-container"; import { Spell } from "../spell/spell"; import { ISpellSearchProps } from "./interfaces/i-spell-search-props"; import { ISpellSearchState } from "./interfaces/i-spell-search-state"; export class SpellSearch extends Component< ISpellSearchProps, ISpellSearchState > { static defaulProps = { spells: [] }; constructor(props) { super(props); this.state = { spells: [], name: "" }; } search() { this.setState({ spells: AdvancedSpellSearch.search(this.props.spells, { name: this.state.name }) }); } handleName(e) { this.setState({ name: e.target.value }, this.search); } componentDidMount() { this.search(); } render() { return (
{this.state.spells.map((spell, index) => { return ( ); })}
); } }