Fix listReport making too many requests

This commit is contained in:
Uku Taht 2021-12-30 10:59:45 +02:00
parent f5fee73363
commit 8fccb4c353
2 changed files with 4 additions and 4 deletions

View File

@ -34,7 +34,7 @@ function Countries({query, site, onClick}) {
function Regions({query, site, onClick}) {
function fetchData() {
return api.get(apiPath(site, '/regions'), query, {country_name: query.filters.country, limit: 9})
return api.get(apiPath(site, '/regions'), query, {limit: 9})
}
function renderIcon(region) {

View File

@ -30,11 +30,11 @@ export default function ListReport(props) {
const [state, setState] = useState({loading: true, list: null})
const valueKey = props.valueKey || 'visitors'
const showConversionRate = !!props.query.filters.goal
const prevProps = useRef();
const prevQuery = useRef();
function fetchData() {
if (typeof(prevProps.current) === 'undefined' || prevProps.current !== props) {
prevProps.current = props;
if (typeof(prevQuery.current) === 'undefined' || prevQuery.current !== props.query) {
prevQuery.current = props.query;
setState({loading: true, list: null})
props.fetchData()
.then((res) => setState({loading: false, list: res}))