On the page I have with reactstrap, I have a checkbox and when this checkbox is checked, I would like the input field to be enabled and if it is unchecked then the input field disabled. How would I go abouts doing this? This is my current code:
import {
Input,
FormGroup,
FormText,
Form,
Label,
Button,
} from "reactstrap";
function HelloWorld() {
let mpinput;
if ((e) => e.target.checked === true) {
mpinput = <Input type="text" name="pmInput" id="pmInput"/>
} else {
mpinput = <Input type="text" name="pmInput" id="pmInput" disabled />
}
return (
...
<FormGroup check>
<Label check>
<Input type="checkbox" id="mpCheckbox" onChange={(e) => console.log(e.target.checked)} />
<Label for="mpinput">Input Field</Label>
{mpinput}
</Label>
</FormGroup>
)
}
export default HelloWorld;
I know I have done something wrong since it is not working how I would like it to, and my guess is that its something to do with the 'if' statement or I am missing something. Sorry if this is a beginners question, I am still working my way through react. Any help would be appreciated.