Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Displaying the Search Results

Parul K
Parul K
201 Points


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;