alsoscotland / react-super-select

MIT License
95 stars 33 forks source link

Got warning when using search field. #87

Closed ilinalexgit closed 7 years ago

ilinalexgit commented 7 years ago

When I start typing into the search filed I receive this warning -

Warning: ReactSuperSelect is changing an uncontrolled input of type undefined to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component.

and after that clear button for search field doesn't erase text.

React version = "react": "15.3.2".

alsoscotland commented 7 years ago

@ilinalexgit Thanks. I will look into it. Can you tell me what version of the control you are on?

ilinalexgit commented 7 years ago

@alsoscotland Thanks for quick response.

"react-super-select": "^0.5.8"

alsoscotland commented 7 years ago

@ilinalexgit no worries. I have not been able to re-produce yet. That warning showed up in newer versions of React I think. I will take a look soon.

ilinalexgit commented 7 years ago

@alsoscotland I think problem is with initializing "searchString" state variable with "undefined" instead of ' ' (empty string).

Please check my commit: https://github.com/ilinalexgit/react-super-select/commit/69f6e5bf95d001a7b6a3009df072d2fece2731b2

alsoscotland commented 7 years ago

@ilinalexgit That looks right. Thank you. I will make that change later tonight

alsoscotland commented 7 years ago

@ilinalexgit https://github.com/alsoscotland/react-super-select/tree/v0.5.9 should address it. Please let me know. Thanks!

ilinalexgit commented 7 years ago

@alsoscotland Works fine now, thanks.

alsoscotland commented 7 years ago

@ilinalexgit Great! Thanks for reporting the issue