Answer the question
In order to leave comments, you need to log in
Am I correctly accepting the data in the rect class?
Guys, hello everyone.
I need your help.
There is such a component
import React, {Component} from 'react';
import {connect} from 'react-redux';
import Helper from './Helper';
import ProgressBar from './ProgressBar';
/**
* class declaration
*/
class DashAnalytics extends Component {
/**
* Renders "DashAnalytics component"
* @return {string} - HTML markup for the component
*/
render() {
const tags = this.props.venues.tagPollination;
const pollination = this.props.venues.pollination;
const totalUsersInTag = (() => {
let totalUsers = 0;
Object.keys(tags).forEach((key) => {
totalUsers += tags[key].totalUsers;
});
return totalUsers;
})();
const totalUsersInPollination = (() => {
let totalUsers = 0;
Object.keys(pollination).forEach((key) => {
totalUsers += pollination[key].totalUsers;
})
return totalUsers;
})();
Object.keys(tags).forEach((key) => {
tags[key].barValue = Math.round((tags[key].totalUsers / totalUsersInTag) * 100);
tags[key].barName = tags[key].tagName;
})
return (
<div className="analytics">
<div className="analitics__lside">
<div className="analitics__header">
<div className="analitics__heading">Top 5 Biggest Pollination Venue</div>
<div className="analitics__help">
<Helper />
</div>
</div>
<div className="analitics__body">
<ProgressBar colorFill='#1b75a2' collorBar='#3399cc'/>
</div>
</div>
<div className="analitics__rside">
<div className="analitics__header">
<div className="analitics__heading">Top 5 Pollination Custom Tags</div>
<div className="analitics__help">
<Helper />
</div>
</div>
<div className="analitics__body">
<ProgressBar analyticData={tags} />
</div>
</div>
</div>
);
}
}
function mapStateProps({venues}) {
return {venues};
}
export default connect(mapStateProps)(DashAnalytics);
Answer the question
In order to leave comments, you need to log in
Why not write a simple check
const totalUsersInPollination = (() => {
let totalUsers = 0;
if (pollination!==undefined && pollination!==null){
Object.keys(pollination).forEach((key) => {
totalUsers += pollination[key].totalUsers;
})
}
return totalUsers;
})();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question