reactjs / react-autocomplete

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

Cannot read property 'ownerDocument' of null when using React Component as item renderer #261

Closed mir3z closed 7 years ago

mir3z commented 7 years ago

See the following example: https://codesandbox.io/s/51mw2Q1K Just uncomment renderItem marked as NOT WORKING and try to navigate by keys on the list. You will see Uncaught TypeError: Cannot read property 'ownerDocument' of null. Everything is fine when renderItem returns plain DOMElement, but in case of ReactComponent error is thrown

CMTegner commented 7 years ago

This problem is due to Item being a functional component. Functional components have no backing instance, and can't be referenced via ref.

Here's a version that works: https://codesandbox.io/s/mQvDw5K2G

It's likely that renderItem and renderMenu will chance significantly for v2.

mir3z commented 7 years ago

Here's a version that works: https://codesandbox.io/s/mQvDw5K2G

It does not work - I can't select menu item by mouse, though key navigation works.

CMTegner commented 7 years ago

My mistake, I forgot to add all the props: https://codesandbox.io/s/zKJQxY6ZZ