Open xizhao opened 9 years ago
Seems like a reasonable request. I think having a separate (optional) callback/function to get the key for an item would be fine.
making displayOption return a component would be fine, provided we have the necessary callbacks to set all the things that have to be strings to strings.
Also, just to make sure, you're pointing out desired new functionality, this didn't regress or anything when we pulled in #61, did it?
@fmoo , not sure, but you can already return a component with displayOption. The problem is it gets cast to a string for the key and all components become of key [object Object]
. Solving the former should enable the latter.
I may be overlooking this but with a quick glance: https://github.com/fmoo/react-typeahead/blob/7702336449eba56708ed7ae3d96c09e555a76dd8/src/typeahead/selector.js#L63-L67
It looks like display string determines key. I don't think this should be the only behavior -- I propose maybe the value from filterOption or another iterating function to be used as the key.
Also having a react component returned from displayOption makes a lot of sense, but it seems like you can't do that.