I have a problem when I wanna get data from state, in console.log appears 2 values. I want remove the empty value, but I've run out of ways. How to remove an empty value?

class DetailOrderTracking extends Component {
constructor(props) {
super(props)
this.state = {
data: []
}
}
componentDidMount = async () => {
const { query } = this.props.router;
var getOrderTrackings = await OrderTrackingRepository.getOrderTracking(query.numberbill, query.courier);
if (getOrderTrackings.ordertracking.status.code == 200) {
var getManifest = getOrderTrackings.ordertracking.result.manifest;
this.setState({ data: getManifest });
}
}
render() {
const { data } = this.state;
console.log(data) // will print 2 values, first condition is empty value, and second condition has values (an example is in the image above)
return (
<div/>
)
}
}
lengthof thedataarray -->data.length. If its zero, array is empty.renderis called. Then you populate the data, andrenderis called again at that point…