Reputation: 636
I want to pass multiple values under value in react class component. Like in value={this.state.port1, this.state.port2, .....etc }
Is there any way?
return (
<ReactAutocomplete
items={this.state.searchData}
shouldItemRender={(item, value) =>
item.NameWoDiacritics.toLowerCase().indexOf(value.toLowerCase()) > -1
}
getItemValue={(item) => item.Name}
renderItem={(item, highlighted) => (
<div
key={item.id}
style={{ backgroundColor: highlighted ? "#eee" : "white" }}
>
{item.Name}
</div>
)}
value={(this.state.Port1, this.state.Port2)}
onChange={(e) => this.childOnChange(e)}
/>
);
Upvotes: 1
Views: 2365
Reputation: 134
You can pass it like an "object".
value={{ this.state.Port1, this.state.Port2}}
or
value={{ value1: this.state.Port1, value2: this.state.Port2 }}
Upvotes: 1
Reputation: 32
You could pass an object
value={{port1: this.state.Port1, port2: this.state.Port2}}
Upvotes: 1