reactjs / react-autocomplete

WAI-ARIA compliant React autocomplete (combobox) component
MIT License
2.17k stars 532 forks source link

'value' is not defined #297

Closed francisrod01 closed 6 years ago

francisrod01 commented 6 years ago

The doc example doesn't work.

<Autocomplete
  getItemValue={(item) => item.label}
  items={[
    { label: 'apple' },
    { label: 'banana' },
    { label: 'pear' }
  ]}
  renderItem={(item, isHighlighted) =>
    <div style={{ background: isHighlighted ? 'lightgray' : 'white' }}>
      {item.label}
    </div>
  }
  value={value}
  onChange={(e) => value = e.target.value}
  onSelect={(val) => value = val}
/>

These last 3 lines don't work. I think the doc will be improved. :+1:

CMTegner commented 6 years ago

This is just pseudo code to give a rough idea of how much work is involved in a minimal implementation. While this may be confusing to people who are new to React, I think it's fairly obvious for most React developers that it's an incomplete example. There are plenty of working examples - including an online editor - where you can copy implementations from.

francisrod01 commented 6 years ago

Well, I cannot learn more about it if this docs is poor about this implementation. Here, a better example to implementation: https://www.npmjs.com/package/react-tag-input So.. thank for al!

CMTegner commented 6 years ago

It is not the responsibility of this repository to teach you about React or JavaScript. There are countless resources available on either of these topics.

I don't appreciate your tone in your last reply. I'm using my spare time to try to maintain a codebase which is free to use. I do not wish to receive snarky comments when I have clearly outlined my reasoning.

I'm locking this thread. Feel free to submit a PR if you want to improve the documentation.