Skip to content

Commit

Permalink
fix: useMemo to prevent Plugin flashing
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Jan 6, 2024
1 parent e833494 commit 27fefe0
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@dhis2/ui'
import cx from 'classnames'
import PropTypes from 'prop-types'
import React, { useEffect, useState } from 'react'
import React, { useEffect, useState, useMemo } from 'react'
import css from 'styled-jsx/css'
import { InterpretationThread } from './InterpretationThread.js'
import { useModalContentWidth } from './useModalContentWidth.js'
Expand Down Expand Up @@ -109,6 +109,13 @@ const InterpretationModal = ({
}
}, [interpretationId, refetch])

const filters = useMemo(
() => ({
relativePeriodDate: interpretation?.created,
}),
[interpretation?.created]
)

return (
<>
{shouldCssHideModal && (
Expand Down Expand Up @@ -156,10 +163,7 @@ const InterpretationModal = ({
<div className="row">
<div className="visualisation-wrap">
<VisualizationPlugin
filters={{
relativePeriodDate:
interpretation.created,
}}
filters={filters}
visualization={visualization}
onResponsesReceived={
onResponsesReceived
Expand Down

0 comments on commit 27fefe0

Please sign in to comment.