首次尝试使用react context api。这是我使用上下文api的反应代码
HTMLElement
onEventSave()异步操作依赖于上一步中的valChanged值,因此必须在调用onEventSave之前将其设置为true。 (在调用STEP 2之前,必须先完成步骤1并将其值设置为true)
这里缺少什么吗?
答案 0 :(得分:3)
如果使用的是钩子,则没有<div class="col-md-6">
<div class="btn-group">
<button type="button" id="all" class="btn btn-success">All</button>
<button type="button" id="ambulance" class="btn btn-primary">Ambulance</button>
<button type="button" id="medicalunit" class="btn btn-danger">Medical Unit</button>
</div>
</div>
<div class="col-md-6 bg-light mt-5">
<div class="row">
<div class="col-md-7">
<h3>Selected Station Services Rating</h3>
<!-- Might not need this block
<p> <b>Type: State</b></p>
<p> <b>Medical unit: Yes</b></p>
<p><b>Ambulance: Yes</b></p>
-->
</div>
<div class="col-md-5 pt-5">
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star-half-o" aria-hidden="true"></i>
</div>
</div>
</div>
</div>
</div>
</div>
leaflet javascript
回调函数,因此可以使用setState
来实现,就像这样:
useEffect
只要更改useEffect(() => {
onEventSave();
},[valChanged]);
,就会调用上述函数