"react/jsx-no-undef error: 'Form' is not defined"
P粉501007768
P粉501007768 2023-08-24 11:45:53
0
1
498
<p> Hi, using the below React application, I need to manage a form to authenticate login to a page, the parameters are email and password, but when I execute the code, the following error is printed, Error: <strong> Line 33: 'Form' is undefined react/jsx-no-undef</strong></p> <p><strong>Javascript code: </strong></p> <pre class="brush:php;toolbar:false;">import React, { Component } from 'react'; import { Button, FormGroup, FormControl, ControlLabel } from "react-bootstrap"; import logo from './logo.svg'; import './Home.css'; class Home extends Component { constructor(props) { super(props); this.state = { email: "", password: "" }; } validateForm() { return this.state.email.length > 0 && this.state.password.length > 0; } handleChange = event => { this.setState({ [event.target.id]: event.target.value }); } handleSubmit = event => { event.preventDefault(); } render() { return ( <div className="Login"> <Form onSubmit={this.handleSubmit}> <Form.Group controlId="email" bsSize="large"> <Form.Control autoFocus type="email" value={this.state.email} onChange={this.handleChange} /> </Form.Group> <Form.Group controlId="password" bsSize="large"> <Form.Control value={this.state.password} onChange={this.handleChange} type="password" /> </Form.Group> <Button block bsSize="large" disabled={!this.validateForm()} type="submit" > Log in </Button> </Form> </div> ); } } export default Home;</pre> <p><br /></p>
P粉501007768
P粉501007768

reply all(1)
P粉238433862

It seems you forgot to import Form, just add it:

import { Form, Button, FormGroup, FormControl, ControlLabel } from "react-bootstrap";
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!