I searched for this and the closest thing I found was this SO post here; however, it does not use React.
I tried this syntax below which is inside a React component:
<input
value={props.value}
onChange={props.onChange}
className={props.className}
placeholder={props.placeholder}
name={props.name} {props.readonly && 'readonly'}>
but I get an eslint parsing error and when I check the UI it is still writable.