2
我在我的项目中安装了一个名为react-geosuggest的反应组件。我需要在<Geosuggest>
组件中找到<label>
dom元素,并将onClick
处理程序插入<label>
。有没有办法在不改变<Geosuggest>
组件代码的情况下将<label>
标签作为目标。反应组件的目标dom元素没有参考
这里的JSX
render() {
return (
<div>
<Geosuggest
id = "searchbar"
label = " "
placeholder = ""
initialValue = {this.state.location}
onChange = {this.onInputChange}
onSuggestSelect = {this.onSelection}
onClick = {this.toggleSearch}
className = {this.state.expand}
inputClassName = {this.state.expand}
// Name a calling reference
ref = 'geosuggest_component'
/>
</div>
);
}
下面是HTML输出
<div class="geosuggest">
<div class="geosuggest__input-wrapper">
<label for="searchbar"></label>
<input class="geosuggest__input" type="text" id="searchbar">
</div>
</div>