I'm trying to enable another input field if the user selects the Other option from the dropdown and I have tried to add a state to the input field which is set to true/false depending on the value selected from the dropdown but I am not able to view the input option when I select other.
const [designation, setDesignation] = useState("");
const [showOption, setShowOption] = useState(false);
<div className="field">
<label className="label">Designation</label>
<div className="control ">
<select
className="input"
id="designation"
name="Your Designation"
value={designation}
type="text"
onChange={(e) => {
setDesignation(e.target.value);
if (value == "3") setShowOption(true);
else setShowOption(false);
}}
placeholder="Your Designation"
required
>
<option value="1">Product Manager</option>
<option value="2">Developer</option>
<option value="3">Other</option>
</select>
</div>
</div>;
{
showOption ? (
<div className="field">
<label className="label">Designation</label>
<div className="control ">
<input
className="input"
id="designation"
value={designation}
type="text"
onChange={(e) => setDesignation(e.target.value)}
placeholder="Your Designation"
required
/>
</div>
</div>
) : (
""
);
}