Skip to content

Commit

Permalink
Update external resources usage (#384)
Browse files Browse the repository at this point in the history
* update externalResources

* Update CHANGELOG.md

---------

Co-authored-by: Mikhail Volkov <[email protected]>
  • Loading branch information
vitPinchuk and mikhail-vl authored Jan 9, 2025
1 parent e437cf2 commit f836225
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features / Enhancements

- Added context.grafana.refresh (#387)
- Updated external resources usage (#384)

## 5.6.0 (2024-12-15)

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/components/TextPanel/TextPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,18 @@ export const TextPanel: React.FC<Props> = ({
[data.series, frameIndex, options.renderMode]
);

/**
* External Resources; use memo to prevent endless call to resources
*/
const externalResources = useMemo(() => {
return options.externalStyles.map((resource) => ({ ...resource, url: replaceVariables(resource.url) }));
}, [options.externalStyles, replaceVariables]);

/**
* External Styles
*/
useExternalResources({
items: options.externalStyles.map((resource) => ({ ...resource, url: replaceVariables(resource.url) })),
items: externalResources,
type: ResourceType.STYLES,
});

Expand Down

0 comments on commit f836225

Please sign in to comment.