I have changed the code from components to hooks. I'm completely new to it and i'm learning react and i need help to change it to hooks what should i do to make it work on functional react ?
- update:
- I have issued the solutions bellow but when i click on the input it takes me to the top of the page
const [nameFocused, setNameFocused] = useState(true);
<FormGroup
className={classnames("mt-5", {
focused: nameFocused,
})}
>
<InputGroup className="input-group-alternative">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="ni ni-user-run" />
</InputGroupText>
</InputGroupAddon>
<Input
placeholder="Your name"
type="text"
onFocus={(e) => setNameFocused(true)}
onBlur={(e) => setNameFocused(false)}
/>
</InputGroup>
</FormGroup>
Not relevant:
<FormGroup
className={classnames("mt-5", {
focused: state.nameFocused,
})}
>
<InputGroup className="input-group-alternative">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="ni ni-user-run" />
</InputGroupText>
</InputGroupAddon>
<Input
placeholder="Your name"
type="text"
onFocus={e => this.setState({ nameFocused: true })}
onBlur={e => this.setState({ nameFocused: false })}
/>
</InputGroup>
</FormGroup>
``