onwordi
3/14/2019 - 1:18 AM

React: Using filter & Map

getList = (event) => {
        const input = this.state.input
        console.log('my input', input)
        const newList = this.props.list.filter(carBrand => {
                console.log('carbrand', carBrand)
                return carBrand.toLowerCase().startsWith(event.toLowerCase())
            })

        console.log(newList)

        this.setState({
            list: newList,
            active: true
        })

    }