Skip to content

Commit 4e23422

Browse files
committed
fix: renderWidget from WidgetConfigurationScreenProps does not update the widget
1 parent cbc6dee commit 4e23422

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## Fixed
11+
12+
- renderWidget from WidgetConfigurationScreenProps does not update the widget
13+
1014
## [0.20.1] - 2026-01-15
1115

1216
## Fixed

src/api/register-widget-configuration-screen.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { AppRegistry } from 'react-native';
33
import { AndroidWidget } from '../AndroidWidget';
44
import { buildWidgetTree } from './build-widget-tree';
5-
import type { WidgetInfo } from './types';
5+
import type { WidgetInfo, WidgetRepresentation } from './types';
66

77
const WIDGET_CONFIGURATION_SCREEN_KEY = 'RNWidgetConfigurationScreen';
88

@@ -14,7 +14,7 @@ export interface WidgetConfigurationScreenProps {
1414
/**
1515
* Function that can be called with the Widget JSX to render
1616
*/
17-
renderWidget: (widgetComponent: React.JSX.Element) => void;
17+
renderWidget: (widgetComponent: WidgetRepresentation) => void;
1818

1919
/**
2020
* This must be called after finishing with configuration.
@@ -45,9 +45,23 @@ function widgetConfigurationScreenProvider(
4545
WidgetConfigurationScreen: WidgetConfigurationScreen
4646
) {
4747
return ({ widgetInfo }: { widgetInfo: WidgetInfo }) => {
48-
function renderWidget(widgetComponent: React.JSX.Element) {
48+
function renderWidget(widgetComponent: WidgetRepresentation) {
49+
const lightWidget =
50+
'light' in widgetComponent
51+
? buildWidgetTree(widgetComponent.light)
52+
: buildWidgetTree(widgetComponent);
53+
const darkWidget =
54+
'dark' in widgetComponent
55+
? buildWidgetTree(widgetComponent.dark as React.JSX.Element)
56+
: null;
57+
58+
const config = {
59+
light: lightWidget,
60+
dark: darkWidget,
61+
};
62+
4963
AndroidWidget.drawWidgetById(
50-
buildWidgetTree(widgetComponent),
64+
config,
5165
widgetInfo.widgetName,
5266
widgetInfo.widgetId
5367
);

0 commit comments

Comments
 (0)