我是一个“带钩子的react引导程序”的初学者,我正在创建一个简单的表单。我正在关注 react-bootstrap 文档的示例,但我遇到了选择/选项表单元素的问题。常规文本输入字段正常呈现,没有错误。选择语句似乎把事情搞砸了。
这是我的代码:
import { Form, Button } from "react-bootstrap";
export default function FormComponentName(props) {
return (
<>
<h1>Search Form</h1>
<Form>
<Form.Group className="mb-3" controlId="searchState">
<Form.Label>State</Form.Label>
<Form.Select defaultValue="State...">
<option>State...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</Form.Select>
</Form.Group>
<Button variant="primary" type="submit">
Search Data
</Button>
</Form>
</>
)
}
这是纱线错误消息:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `FormComponentName`.
从控制台:
index.js:1 Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check your code at FormComponentName.js:14.
at FormComponentName
我需要安装一个额外的模块,还是更明显的?
代替
Form.Select
,您可以使用: