react-typeahead
react-typeahead copied to clipboard
Documentation about `defaultValue` and `allowCustomValues`
Hi!
What is the function of these? Are included in the latest release?
I've tested defaultValue
and it is not working on 1.0.4.
Any quick ideas about them?
Thanks! Fran
I think defaultValue serves to have the tokenizer check and display values that partially match. It makes the TypeAheadSelector display if you have matching values in the options array.
On Fri, May 8, 2015 at 3:40 PM, Francisco Guijarro <[email protected]
wrote:
Hi! What is the function of these? Are included in the latest release? I've tested defaultValue and it is not working on 1.0.4.
Any quick ideas about them?
Thanks! Fran
— Reply to this email directly or view it on GitHub https://github.com/fmoo/react-typeahead/issues/73.
With string literals it works:
defaultValue="something"
but with bindings it does not
defaultValue={this.state.someVar}
but with bindings it does not
defaultValue={this.state.someVar}
Is this.state.someVar set to a string? That should be working. Are you getting an error message?
@fmoo no error message, just nothing is displayed on the input inside the typeahead
Originally someVar
has nothing and after a couple of seconds it gets a string value.
This does not work either:
{"some string"}
This is really strange. Were you using the latest version of react everywhere in your project?
Hi, I use React 0.14.0-alpha3 and I have the same exact problem.
The same here with React 0.13.3.
A basic workaround that partially works for me :
<Input type='text' id='ShortName' placeholder='Enter short name' defaultValue={${this.state.ShortName}
} />
But it does not refresh the value when
setState({ShortName: 'toto'}) is called in success of an ajax call.
Any idea ?
having this same issue:
defaultValue={selectedCity}
doesn't work for me but defaultValue="asdf"
does. also weird is that placeholder={selectedCity}
works correctly but with bindings defaultValue
(and value
) do not
EDIT: @fmoo, figured out the issue. this.props.entryValue
is what's being passed to the input element's value
attribute, but that's set in getInitialState()
, which won't get overridden if the typeahead component is re-rendered with an updated value
or defaultValue
.
the issue is being addressed here: https://github.com/fmoo/react-typeahead/pull/133