Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Replace useId with a communication react specific id generator for React 16",
"packageName": "@azure/communication-react",
"email": "edwardlee@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Replace useId with a communication react specific id generator for React 16",
"packageName": "@azure/communication-react",
"email": "edwardlee@microsoft.com",
"dependentChangeType": "patch"
}
3 changes: 3 additions & 0 deletions packages/acs-ui-common/review/beta/acs-ui-common.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const fromFlatCommunicationIdentifier: (id: string) => CommunicationIdent
// @public
export type FunctionWithKey<KeyT, ArgsT extends unknown[], RetT> = (key: KeyT, ...args: ArgsT) => RetT;

// @internal
export const _generateUniqueId: () => string;

// @internal
export const _getApplicationId: () => string;

Expand Down
3 changes: 3 additions & 0 deletions packages/acs-ui-common/review/stable/acs-ui-common.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const fromFlatCommunicationIdentifier: (id: string) => CommunicationIdent
// @public
export type FunctionWithKey<KeyT, ArgsT extends unknown[], RetT> = (key: KeyT, ...args: ArgsT) => RetT;

// @internal
export const _generateUniqueId: () => string;

// @internal
export const _getApplicationId: () => string;

Expand Down
9 changes: 9 additions & 0 deletions packages/acs-ui-common/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ export const _preventDismissOnEvent = (
): boolean => {
return ev.type === 'resize' || ev.type === 'scroll';
};

/**
* @internal
* * Generate a unique id
* TODO: Replace with useId() once React 18 becomes a required dependency.
*/
export const _generateUniqueId = (): string => {
return 'acr-' + self.crypto.getRandomValues(new Uint32Array(1))[0].toString(16);
};
2 changes: 1 addition & 1 deletion packages/acs-ui-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export {
export { _getApplicationId } from './telemetry';
export { _formatString } from './localizationUtils';
export { _safeJSONStringify } from './safeStringify';
export { _convertRemToPx, _preventDismissOnEvent } from './common';
export { _convertRemToPx, _preventDismissOnEvent, _generateUniqueId } from './common';

export type { Common, CommonProperties } from './commonProperties';
export type { CallbackType, FunctionWithKey } from './memoizeFnAll';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Stack,
Text
} from '@fluentui/react';
import React, { useId, useMemo, useRef, useState } from 'react';
import React, { useMemo, useRef, useState } from 'react';
import { useIdentifiers } from '../identifiers';
import { useLocale } from '../localization';
import { useTheme } from '../theming';
Expand All @@ -32,6 +32,7 @@ import { _preventDismissOnEvent as preventDismissOnEvent } from '@internal/acs-u
/* @conditional-compile-remove(one-to-n-calling) */
/* @conditional-compile-remove(PSTN-calls) */
import { ParticipantState } from '../types';
import { _generateUniqueId } from '@internal/acs-ui-common';

/**
* Fluent styles for {@link ParticipantItem}.
Expand Down Expand Up @@ -159,7 +160,7 @@ export const ParticipantItem = (props: ParticipantItemProps): JSX.Element => {
const theme = useTheme();
const localeStrings = useLocale().strings.participantItem;
const ids = useIdentifiers();
const uniqueId = useId();
const uniqueId = _generateUniqueId();

const strings = { ...localeStrings, ...props.strings };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import React, { useId, useMemo } from 'react';
import React, { useMemo } from 'react';
import {
participantListContainerStyle,
participantListMobileStyle,
Expand All @@ -17,6 +17,7 @@ import {
} from '@internal/react-components';
import { FocusZone, Stack, Text, useTheme } from '@fluentui/react';
import { AvatarPersona, AvatarPersonaDataCallback } from './AvatarPersona';
import { _generateUniqueId } from '@internal/acs-ui-common';

type ParticipantContainerProps = {
onRenderAvatar?: OnRenderAvatarCallback;
Expand Down Expand Up @@ -51,7 +52,7 @@ export const ParticipantListWithHeading = (props: {
onFetchParticipantMenuItems?: ParticipantMenuItemsCallback;
}): JSX.Element => {
const { onFetchAvatarPersonaData, onFetchParticipantMenuItems, title, participantListProps } = props;
const subheadingUniqueId = useId();
Comment thread
edwardlee-msft marked this conversation as resolved.
const subheadingUniqueId = _generateUniqueId();
const theme = useTheme();
const subheadingStyleThemed = useMemo(
() => ({
Expand Down