Skip to content

Commit

Permalink
fix: add translucent prop to CachedDataQueryProvider (DHIS2-18029) (#…
Browse files Browse the repository at this point in the history
…1699)

translucent is optional and defaults to same value as before: true
In CachedDataQueryProvider, the translucent prop of the Layer component 
was always true caused flashing grey backgrounds when loading main maps-app
and its plugin in dashboard.
  • Loading branch information
BRaimbault authored Sep 12, 2024
1 parent 66cd146 commit ae4dbe6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/CachedDataQueryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ import React, { createContext, useContext } from 'react'

const CachedDataQueryCtx = createContext({})

const CachedDataQueryProvider = ({ query, dataTransformation, children }) => {
const CachedDataQueryProvider = ({
query,
dataTransformation,
children,
translucent = true,
}) => {
const { data: rawData, ...rest } = useDataQuery(query)
const { error, loading } = rest
const data =
rawData && dataTransformation ? dataTransformation(rawData) : rawData

if (loading) {
return (
<Layer translucent>
<Layer translucent={translucent}>
<CenteredContent>
<CircularLoader />
</CenteredContent>
Expand Down Expand Up @@ -43,6 +48,7 @@ CachedDataQueryProvider.propTypes = {
children: PropTypes.node.isRequired,
query: PropTypes.object.isRequired,
dataTransformation: PropTypes.func,
translucent: PropTypes.bool,
}

const useCachedDataQuery = () => useContext(CachedDataQueryCtx)
Expand Down

0 comments on commit ae4dbe6

Please sign in to comment.