我遇到未定义的“查找”问题。(未捕获的TypeError:无法读取未定义的属性“查找”)我无法自行解决,请参见下面的代码。
class NetworkingEdit extends Component {
state = {
isLoading: true,
data: null
};
componentDidMount() {
const paramsID = this.props.match.params.id;
const { NetworkingData } = this.props;
let currentEvent = NetworkingData.find(networking => {
return networking.id == paramsID;
});
this.setState({
isLoading: false,
data: currentEvent
});
}
render() {
return this.state.isLoading ? (
<div>
<p>Getting your data...</p>
</div>
) : (
<NetworkingMainForm
{...this.props}
data={this.state.data}
id={this.props.match.params.id}
addForm={false}
/>
);
}
}
答案 0 :(得分:0)
您是否从父组件传递了NetworkingData
道具?如果是这样,它是数组吗?