moroshko / react-autowhatever

Accessible rendering layer for Autosuggest and Autocomplete components
http://react-autowhatever.js.org
MIT License
164 stars 71 forks source link

renderInputComponent if undefined, should bring back default input #41

Open eldyvoon opened 6 years ago

eldyvoon commented 6 years ago

Are you reporting a bug?

renderInputComponent is not optional? when it's undefined it should render the default input component. For now I have to do this


if (custom) {
  return (
    <Autosuggest
      {...props}
      renderInputComponent={() => this.customComponent()}
    />
  )
}

return `<Autosuggest  {...props} renderInputComponent={() => this.customComponent()} />`

I expect it work like below where I can put condition in jsx, but it does not

return <Autosuggest {...props} renderInputComponent={custom ? () => this.customComponent : undefined} />

Above code initially show a blank input when renderInputComponent is optional.

tdhung80 commented 5 years ago

Hi,

Just not to specify a render function to renderInputComponent, it would work. In your case, code should be

` if (custom) return <Autosuggest {...props} renderInputComponent={ this.customComponent } />

return <Autosuggest {...props} /> `

My Bests, Hung Tran