I want to select the associated value of the input select form handleInput in select component to make an issue
C:xampphtdocslaravel-projectclub_member_ship_fypresourcesjsComponentsInputSelect.jsx: Unexpected token, expected "…" (11:59)
14 |
<div className="mb-2">
<InputLabel htmlFor="membershipType" value="Select Membership Type" />
<InputSelect options={memberShipType} handleInput={handleInput} id="memberShipTypes" name="member_ship_type" handleChange={handleChange} />
<div className="text-red-500">{fieldErrors.member_ship_type}
</div>
</div>
'use client';
import { Select } from 'flowbite-react';
let InputSelect = ({ options, handleInput, name, id, handleChange }) => {
return (
<div className="max-w-screen-md">
<Select id={id} name={name} value={handleInput.member_ship_type} onChange={handleChange}>
{options.map((item) => (
<option value={item.member_ship_type} {handleInput.member_ship_type == item.member_ship_type ? 'selected' : ''} key={item.member_ship_type}>{item.label}</option>
))}
</Select>
</div >
);
}
export default InputSelect;
2
Answers
Here is the correct code
To select the associated value of an input select form when handling user input in a React component, you can use the onChange event handler to capture the selected value and update the component’s state accordingly. Here’s an example of how you can achieve this:
Assuming you have a element in your component’s JSX: