mirror of
https://github.com/plausible/analytics.git
synced 2024-11-26 23:27:54 +03:00
Fix listReport making too many requests
This commit is contained in:
parent
f5fee73363
commit
8fccb4c353
@ -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) {
|
||||
|
@ -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}))
|
||||
|
Loading…
Reference in New Issue
Block a user