我正在尝试创建一个带有一些复选框的下拉菜单。我发现这个参考并认为非常有价值。我在我的示例代码中实现了它,但我得到了function is declared but its value is never used
错误并且不明白为什么。
在我正在使用的代码片段下方:
import React from 'react';
import styled from 'styled-components';
import { Table } from 'reactstrap';
import GoogleMapReact from 'google-map-react';
import { Card, CardImg, CardText, CardBody, CardTitle, /*CardSubtitle,*/ Button } from 'reactstrap';
const MapContainer = styled.div`
some data....
`;
var expanded = false;
function showCheckboxes() {
var checkboxes = document.getElementById('checkboxes');
if (!expanded) {
checkboxes.style.display = 'block';
expanded = true;
} else {
checkboxes.style.display = 'none';
expanded = false;
}
}
const BoatMap = () => (
<div className="google-map">
<GoogleMapReact
bootstrapURLKeys={{ key: 'MY_KEY' }}
center={{
lat: 42.4,
lng: -71.1
}}
zoom={11}
>
{/* Insert components here */}
<form>
<div class="multiselect">
<div class="selectBox" onClick="showCheckboxes()">
<select>
<option>Select an option</option>
</select>
<div class="overSelect" />
</div>
<div id="checkboxes">
<label for="one">
<input type="checkbox" id="one" />First checkbox
</label>
<label for="two">
<input type="checkbox" id="two" />Second checkbox
</label>
<label for="three">
<input type="checkbox" id="three" />Third checkbox
</label>
</div>
</div>
</form>
</GoogleMapReact>
</div>
);
export default function GoogleMap() {
return (
<MapContainer>
</MapContainer>
);
}
到目前为止我做了什么:
除了进行大量研究之外,我还查看了这份文档以确保所有内容都正确设置。我觉得是这样的。
我还发现了这篇有用的帖子,其中包含大量信息并在其中挖掘了一些内容,但我不确定是否与我的错误完全相关。
我使用<form>
了 ,尽管我仍在学习这种类型的组件并认为这可能是一个很好的练习。我不确定这个错误是否可能是由于这一点。
感谢您指出解决问题的正确方向。