当我收到以下错误时,我正在使用 React。
TypeError: react__WEBPACK_IMPORTED_MODULE_2___default(...) is not a function
我该如何解决这个问题?我在下面添加了代码。
import React from 'react';
import LoginForm from './loginForm'
import useState from "react"
function LoginPage(){
const[details, setDetails] = useState({
username: '',
password: ''
});
function handleChange(event){
const updatedDetails = {...details, [event.target.name]: event.target.value};
setDetails(updatedDetails)
}
return(<LoginForm details={details} onChange={handleChange}/>)
};
export default LoginPage;
另一个组件是:-
import React from "react";
import 'bootstrap/dist/css/bootstrap.min.css';
import { Jumbotron, Container } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input, FormText } from 'reactstrap';
function FormPage(props){
return (
<Jumbotron fluid>
<Container fluid>
<center><h1 className="display-3"> Log IN</h1></center>
<p className="lead">Please Enter your Details Here</p>
</Container><br />
<Container fluid>
<Form>
<FormGroup>
<Label for="username">Username</Label>
<Input type="textarea" name="username" id="username" placeholder="Enter your Username Here" value={props.details.username} onChange={props.onChange}></Input>
</FormGroup>
<FormGroup>
<Label for="password">Password</Label>
<Input type="password" name="password" id="password" placeholder="Enter your Password Here" value={props.details.username} onChange={props.onChange}></Input>
</FormGroup>
<Button color="success">Submit</Button>
</Form>
</Container>
</Jumbotron>
);
};
export default FormPage;
PS:我输入这个是因为 StackOverflow 要求我添加更多细节,因为我的问题主要是代码。对不起。