Skip to content

Commit a85e723

Browse files
authored
fix: default options (re-renders not firing by default) (#905)
When I was adding the general `suspend` option as @lukas-reining suggested (a way to enable/disable all suspense features) I broke the default options. I found this writing tests in a different branch. Tests for the entire SDK including this are incoming shortly (today), but this is a fix for the issue. --------- Signed-off-by: Todd Baert <[email protected]>
1 parent 0eefa84 commit a85e723

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/react/src/common/options.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@ export const DEFAULT_OPTIONS: ReactFlagEvaluationOptions = {
6262
* @param {ReactFlagEvaluationOptions} options options to normalize
6363
* @returns {NormalizedOptions} normalized options
6464
*/
65-
export const normalizeOptions: (options?: ReactFlagEvaluationOptions) => NormalizedOptions = (options?: ReactFlagEvaluationOptions) => {
66-
const defaultOptionsIfMissing = !options ? {} : options;
67-
// fall-back the suspense options
68-
const suspendUntilReady = 'suspendUntilReady' in defaultOptionsIfMissing ? defaultOptionsIfMissing.suspendUntilReady : defaultOptionsIfMissing.suspend;
69-
const suspendWhileReconciling = 'suspendWhileReconciling' in defaultOptionsIfMissing ? defaultOptionsIfMissing.suspendWhileReconciling : defaultOptionsIfMissing.suspend;
65+
export const normalizeOptions: (options?: ReactFlagEvaluationOptions) => NormalizedOptions = (options: ReactFlagEvaluationOptions = {}) => {
66+
const updateOnContextChanged = options.updateOnContextChanged;
67+
const updateOnConfigurationChanged = options.updateOnConfigurationChanged;
68+
69+
// fall-back the suspense options to the catch-all `suspend` property
70+
const suspendUntilReady = 'suspendUntilReady' in options ? options.suspendUntilReady : options.suspend;
71+
const suspendWhileReconciling = 'suspendWhileReconciling' in options ? options.suspendWhileReconciling : options.suspend;
72+
7073
return {
71-
updateOnContextChanged: defaultOptionsIfMissing.updateOnContextChanged,
72-
updateOnConfigurationChanged: defaultOptionsIfMissing.updateOnConfigurationChanged,
7374
// only return these if properly set (no undefined to allow overriding with spread)
7475
...(typeof suspendUntilReady === 'boolean' && {suspendUntilReady}),
7576
...(typeof suspendWhileReconciling === 'boolean' && {suspendWhileReconciling}),
77+
...(typeof updateOnContextChanged === 'boolean' && {updateOnContextChanged}),
78+
...(typeof updateOnConfigurationChanged === 'boolean' && {updateOnConfigurationChanged}),
7679
};
7780
};

0 commit comments

Comments
 (0)