从父组件到子组件的传递功能不起作用

时间:2020-07-03 07:55:07

标签: javascript reactjs

该功能未触发。我检查了许多其他答案,似乎我的代码应该可以正常工作。

应用内父组件:

update() {
  console.log("hello");
}

<PrivateRoute
  exact
  path="/profile"
  component={Profile}
  update={this.update}
/>

在“个人资料”子组件中:

<button
  type="button"
  onClick={this.props.update}
>

1 个答案:

答案 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

希望这会有所帮助。