Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Displaying the Search Results

Parul K
Parul K
201 Points

Filters

How do I implement component filter for this App - https://teamtreehouse.com/library/displaying-the-search-results Guil Hernandez

example source filter code

import React, { Component } from "react"; import Select from "react-select"; let source = ["https://www.tumblr.com","www.youtube.com","www.nbc.com","www.princeestate.com", "www.bbc.co.uk","bit.ly","hbo.com/game-of-thrones","MenInBlack.com"]; let options = [];

options = options.concat(source.map(x => x));

function MakeOption(x) { return { value: x, label: x }; }

class SourceFilter extends Component { constructor(props) { super(props); this.state = { value: "" }; } handleInputChange = (value, e) => { if (e.action === "input-change") { this.setState({ value }); } }; render() { return ( <Select isMulti name="colors" options={options.map(x => MakeOption(x))} className="basic-multi-select" classNamePrefix="select" closeMenuOnSelect={false} onInputChange={this.handleInputChange} inputValue={this.state.value} /> ); } } export default SourceFilter;