react-select:如何解决“警告:Prop \`id\` 不匹配”

新手上路,请多包涵

我有一个带有 ReactJs 和 NextJs 的网络应用程序。在一个功能组件中,我使用了 react-select 然后,我收到以下控制台警告:

警告:道具 id 不匹配。服务器:“react-select-7-input” 客户端:“react-select-2-input”

我的代码如下:

 import { Row, Col, Card, Form, Button } from 'react-bootstrap';
import Select from 'react-select';

const priorityOptions = [
  { value: 'p1', label: 'Top level - P1' },
  { value: 'p2', label: 'Mid level - P2' },
  { value: 'p3', label: 'Low level - P3' }
];
const PostView = () => {
  return (
    <div className="DashboardSla-ContentBody__Form">
      <Row>
        <Col md="10">
          <Card className="shadow-sm">
            <Card.Body>
              <Form>
                <h5 className="text-secondary mb-3">Booking details</h5>
                <Form.Group controlId="postType">
                  <Form.Label>Booking priority</Form.Label>
                  <Select
                    id="postType"
                    placeholder="Make a selection"
                    options={priorityOptions}
                  />
                </Form.Group>
                <Button
                  type="submit"
                  variant="primary"
                >Add Booking</Button>
              </Form>
            </Card.Body>
          </Card>
        </Col>
      </Row>
    </div>
  )
}

export default PostView;

原文由 Sonjoy Datta 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 486
1 个回答

尝试添加 prop instanceId 设置为唯一字符串并且应该可以工作

原文由 xargr 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题