import React from 'react'; import {Link} from 'react-router-dom'; class TopicsList extends React.Component { constructor() { super(); this.state = { currentFilter: "", filteredTopics: [], } } componentDidMount() { this.setState({ filteredTopics: this.props.allTopics }) } filterTopics(event) { // find the topics that contain that string // return filtered topics. // this. const input = event.target.value.toLowerCase(); this.setState({ filteredTopics: this.props.allTopics.filter(topic => topic.name.toLowerCase().indexOf(input) !== -1) }) } render() { return (
{this.state.filteredTopics.map(topic => { return (

{topic.name} ({topic.items} videos)

) } )}
) } } export default TopicsList;