componentWillReceiveProps =(newProps)=> {
const _self = this;
//console.log("");
//console.log("newProps = ", newProps["basicInformationData"]);
let videoLength = 0;
let videoSize = 0;
let distanceCreationTime = 0;
let tags = []
if( newProps["basicInformationData"] !== undefined) {
if ( newProps["basicInformationData"]["distance_time"] !== undefined ) {
distanceCreationTime = newProps["basicInformationData"]["distance_time"]
}
if ( newProps["basicInformationData"]["duration"] !== undefined ) {
videoLength = newProps["basicInformationData"]["duration"]
}
if ( newProps["basicInformationData"]["size"] !== undefined ) {
videoSize = newProps["basicInformationData"]["size"]
}
if ( newProps["basicInformationData"]["tags"] !== undefined ) {
tags = newProps["basicInformationData"]["tags"]
}
}
_self.setState({
tags: tags, //
videoLength: videoLength,
videoSize: videoSize,
distanceCreationTime: distanceCreationTime
})
}
how to optimize the following paragraph?
_self.setState({
tags: tags, //
videoLength: videoLength,
videoSize: videoSize,
distanceCreationTime: distanceCreationTime
})
how to optimize this if
if( newProps["basicInformationData"] !== undefined) {
if ( newProps["basicInformationData"]["distance_time"] !== undefined ) {
distanceCreationTime = newProps["basicInformationData"]["distance_time"]
}
if ( newProps["basicInformationData"]["duration"] !== undefined ) {
videoLength = newProps["basicInformationData"]["duration"]
}
if ( newProps["basicInformationData"]["size"] !== undefined ) {
videoSize = newProps["basicInformationData"]["size"]
}
if ( newProps["basicInformationData"]["tags"] !== undefined ) {
tags = newProps["basicInformationData"]["tags"]
}
}