Skip to content

Can't select items randomly #19

@OZZlE

Description

@OZZlE

I'm a newbie at React so bare with me, but I got this working however I can only select items half of the time or less..

  1. I created my App using this: https://github.com/facebookincubator/create-react-app
  2. ran npm install react-search --save inside the app folder

And then added this js code to my App:

import Search from 'react-search'
import React, { Component } from 'react'
 
class App extends Component {

  HiItems(items) {
      this.setState({ repos: items })
  }

  constructor (props) {
    super(props)
    this.state = {
      repos: []
    }
  }

  getItemsAsync(searchValue, cb) {
    let url = `https://jsonplaceholder.typicode.com/todos`
    fetch(url).then( (response) => {
      return response.json();
    }).then((results) => {
      if (typeof results !== "undefined"){
        let items = results.map( (res, i) => { return { id: i, value: res.title } })
        cb(searchValue)
        this.setState({ repos: items })        
      }
    });
  }

  render () {

    return (
      <div>
        <Search items={this.state.repos} />

        <Search items={this.state.repos}
                multiple={true}
                getItemsAsync={this.getItemsAsync.bind(this)}
                onItemsChanged={this.HiItems.bind(this)} />
      </div>
    )
  }
}
export default App;

but I can only select items half of the time, here is a video of me trying to select: https://sendvid.com/emr6tqhq

I copied the css from the example folder in node_modules/react-search/example/public/react-search.css

Tested using Chrome Version 54.0.2840.98 (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions