How to use 'this.props.params' in React?
问题 I send a certain id (idValue) to my component and use it like this: componentDidMount() { this.onHandleFetch(this.props.params.idValue); } But sometimes this component opens without any input parameters (without idValue) and I got this error: TypeError: Cannot read property 'idValue' of undefined How can I fix it? I've tried to use typeof , but it was unsuccessful In the component from which the value is transferred, I use context router 回答1: static defaultProps = { params:{} } 回答2: The error