nkbt / react-debounce-input

React component that renders Input with debounced onChange
MIT License
451 stars 61 forks source link

Add support for loading state to custom Input component #152

Closed Nithur-M closed 2 years ago

Nithur-M commented 2 years ago

I want to display the loading state inside my custom Input component. It'd be helpful if you can add support for passing loading state.

nkbt commented 2 years ago

Loading state is not a concern of an input. It can be solved by wrapping input and adding loading ui + props to that new component. That is a specific app concern

Nithur-M commented 2 years ago

Loading state is not a concern of an input. It can be solved by wrapping input and adding loading ui + props to that new component. That is a specific app concern

When I pass props to the component it throws an unsupported type error. (error: expected string but got an object). Is it possible to send props to the custom component by any other means?

nkbt commented 2 years ago

I have no idea what you are doing.

Nithur-M commented 2 years ago

I couldn't pass any props as follows: <DebounceInput minLength={3} debounceTimeout={300} element={CustomInput(props)} onChange={changeHandler} /> It throws the above mentioned error. How am I supposed to pass the loading state to my customInput? Thank you.

nkbt commented 2 years ago

Arbitrary props will be passed through to the input element https://github.com/nkbt/react-debounce-input#arbitrary-props-will-be-transferred-to-rendered-input

Nithur-M commented 2 years ago

Thank you so much.