react-typeahead icon indicating copy to clipboard operation
react-typeahead copied to clipboard

Documentation about `defaultValue` and `allowCustomValues`

Open franleplant opened this issue 9 years ago • 8 comments

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

franleplant avatar May 08 '15 22:05 franleplant

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.

thehuey avatar May 08 '15 22:05 thehuey

With string literals it works:

defaultValue="something"

but with bindings it does not

defaultValue={this.state.someVar}

franleplant avatar May 08 '15 23:05 franleplant

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 avatar May 09 '15 07:05 fmoo

@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"}

franleplant avatar May 09 '15 15:05 franleplant

This is really strange. Were you using the latest version of react everywhere in your project?

fmoo avatar Jun 13 '15 08:06 fmoo

Hi, I use React 0.14.0-alpha3 and I have the same exact problem.

danielsoner avatar Jun 18 '15 16:06 danielsoner

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 ?

jprogertest avatar Jul 28 '15 08:07 jprogertest

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

kitdesai avatar Oct 21 '15 17:10 kitdesai