question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Autosuggest throws an exception when value is 'number'

See original GitHub issue

For my form I need to pre-fill the value from server which end up as Integers.

But when I try to pass that to Autosuggest it fails, It does not have issues with String. Those work just fine

https://codepen.io/anon/pen/QQaxeP

Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).trim is not a function
    at Autosuggest.getQuery (Autosuggest.js:280)
    at Autosuggest.render (Autosuggest.js:497)
    at finishClassComponent (react-dom.development.js:7873)
    at updateClassComponent (react-dom.development.js:7850)
    at beginWork (react-dom.development.js:8225)
    at performUnitOfWork (react-dom.development.js:10224)
    at workLoop (react-dom.development.js:10288)
    at HTMLUnknownElement.callCallback (react-dom.development.js:542)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:581)
    at invokeGuardedCallback (react-dom.development.js:438)
    at renderRoot (react-dom.development.js:10366)
    at performWorkOnRoot (react-dom.development.js:11014)
    at performWork (react-dom.development.js:10967)
    at batchedUpdates (react-dom.development.js:11086)
    at batchedUpdates (react-dom.development.js:2330)
    at dispatchEvent (react-dom.development.js:3421)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:13
  • Comments:8

github_iconTop GitHub Comments

4reactions
0004072commented, Oct 1, 2018

Seems like, the value parameter expects a string. Converting the value to a string using toString resolved the problem for me.

3reactions
rvighnescommented, Nov 15, 2020

@matheuspoleza I got the same error and finally found out where I made an error : My onChange function (passed via the inputProps attribute) didn’t destruct the newValue from the object :

onChange = (event, { newValue }) => {...}

instead of

onChange = (event, newValue) => {...}

By setting an object (containing the newValue attribute) instead of the string, it’s impossible for AutoSuggest to call the trim method on it. Hope that helped !

In the onChange handler, I was using event.target.value to update my value. When I used the de-structured value of the second parameter (event, { newValue }), it worked. Thanks for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Autosuggest throwing error on clicking the suggestions
When you click a suggestion, the value of the "value" key in the inputProps is undefined thats the reason that you are getting...
Read more >
445727 - Web form autocomplete throws uncaught exception when ...
Open and clear the error console 2. Go to a page (eg. google.com) with an input text box that you've used before 3....
Read more >
Enter custom value causes exception in Blazor WASM ...
The following exception occurs when we type a custom value and press enter in allowCustom enabled autocomplete. Error: System.
Read more >
Autocomplete FormField throws error and no results
06.09.2018 13:27:40 ERROR - Controller Form has raised an exception in Action ReloadAutoCompleteField. System.NullReferenceException: Der Objektverweis wurde ...
Read more >
Errors - discord.js Guide
This error is caused by spawning a large number of event listeners, usually for the client. The most common cause of this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found