该功能未触发。我检查了许多其他答案,似乎我的代码应该可以正常工作。
应用内父组件:
update() {
console.log("hello");
}
<PrivateRoute
exact
path="/profile"
component={Profile}
update={this.update}
/>
在“个人资料”子组件中:
<button
type="button"
onClick={this.props.update}
>
答案 0 :(得分:2)
我认为在if 'Address' in text_string and 'Phone' in text_string:
try:
pos_1 = text_string.index('Address')
pos_2 = text_string.index('Phone')
output['address'] = text_string[pos_1+7:pos_2]
except ValueError:
output['address'] = None
中,您没有将PrivateRoute
方法传递给update
组件。
Profile
希望这会有所帮助。