Skip to content

Commit adcdec9

Browse files
authored
fix: SSR hydration mismatch from Date.now private prop keys (adobe#9787)
1 parent f61a617 commit adcdec9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/@react-aria/datepicker/src/useDateField.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ export const hookData: WeakMap<DateFieldState, HookData> = new WeakMap<DateField
5555

5656
// Private props that we pass from useDatePicker/useDateRangePicker.
5757
// Ideally we'd use a Symbol for this, but React doesn't support them: https://github.com/facebook/react/issues/7552
58-
export const roleSymbol: string = '__role_' + Date.now();
59-
export const focusManagerSymbol: string = '__focusManager_' + Date.now();
58+
// These need to be stable across server and client module evaluation for SSR hydration.
59+
export const roleSymbol: string = '__reactAriaDateFieldRole';
60+
export const focusManagerSymbol: string = '__reactAriaDateFieldFocusManager';
6061

6162
/**
6263
* Provides the behavior and accessibility implementation for a date field component.

packages/@react-stately/form/src/useFormValidationState.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ export const DEFAULT_VALIDATION_RESULT: ValidationResult = {
4141

4242
export const FormValidationContext: Context<ValidationErrors> = createContext<ValidationErrors>({});
4343

44-
export const privateValidationStateProp: string = '__formValidationState' + Date.now();
44+
// Private props that we pass from useFormValidationState to children.
45+
// Ideally we'd use a Symbol for this, but React doesn't support them: https://github.com/facebook/react/issues/7552
46+
// This needs to be stable across server and client module evaluation for SSR hydration.
47+
export const privateValidationStateProp: string = '__reactAriaFormValidationState';
4548

4649
interface FormValidationProps<T> extends Validation<T> {
4750
builtinValidation?: ValidationResult,

0 commit comments

Comments
 (0)