The code below does hides/shows if in the conditional rendering is only one element either label or text input but it doesn't work if I want to hide both elements. I need solution which will hide at least 2 or more elements.
{trueMode === false && (<label htmlFor="car">Car</label> &&
<input onChange={handleChange} id="car"
value={newVehicle.car} type="text" />)}
CodePudding user response:
You have to wrap the elements with a fragment for example
{trueMode === false && (
<>
<label htmlFor="car">Car</label>
<input onChange={handleChange} id="car" value={newVehicle.car} type="text" />
</>
)}