Skip to content

Commit

Permalink
fix: prevent list of TET dimensions from not being fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Nov 3, 2023
1 parent 59fd9e8 commit 48f58b3
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@ const query = {
const useTrackedEntityDimensions = ({ visible, searchTerm, nameProp, id }) => {
const [isListEndVisible, setIsListEndVisible] = useState(false)
const [dimensions, setDimensions] = useState(null)
const { data, error, loading, fetching, called, refetch } = useDataQuery(
query,
{
lazy: true,
}
)
const { data, error, loading, fetching, refetch } = useDataQuery(query, {
lazy: true,
})

useEffect(() => {
// Delay initial fetch until component comes into view
if (visible && !called) {
if (visible && !dimensions) {
refetch({ page: 1, nameProp, id })
}
}, [visible, called, id])
}, [visible])

useEffect(() => {
// Reset when filter changes
setDimensions(null)
if (visible) {
refetch({
page: 1,
Expand All @@ -55,9 +54,7 @@ const useTrackedEntityDimensions = ({ visible, searchTerm, nameProp, id }) => {
id,
})
}
// Reset when filter changes
setDimensions(null)
}, [searchTerm, nameProp, id, visible])
}, [searchTerm, id])

useEffect(() => {
if (data) {
Expand Down

0 comments on commit 48f58b3

Please sign in to comment.