Skip to content

Commit

Permalink
default to empty string identifier prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed May 31, 2022
1 parent b224f07 commit 2c4a074
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions packages/react-server/src/ReactFlightHooks.js
Expand Up @@ -107,10 +107,7 @@ function useId(): string {
if (currentRequest === null) {
throw new Error('useId can only be used while React is rendering');
}
const prefix = currentRequest.identifierPrefix
? currentRequest.identifierPrefix
: '';
const id = currentRequest.identifierCount++;
// use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
return ':' + prefix + 'S' + id.toString(32) + ':';
return ':' + currentRequest.identifierPrefix + 'S' + id.toString(32) + ':';
}
4 changes: 2 additions & 2 deletions packages/react-server/src/ReactFlightServer.js
Expand Up @@ -108,7 +108,7 @@ export type Request = {
writtenSymbols: Map<Symbol, number>,
writtenModules: Map<ModuleKey, number>,
writtenProviders: Map<string, number>,
identifierPrefix?: string,
identifierPrefix: string,
identifierCount: number,
onError: (error: mixed) => void,
toJSON: (key: string, value: ReactModel) => ReactJSONValue,
Expand Down Expand Up @@ -148,7 +148,7 @@ export function createRequest(
writtenSymbols: new Map(),
writtenModules: new Map(),
writtenProviders: new Map(),
identifierPrefix,
identifierPrefix: identifierPrefix || '',
identifierCount: 1,
onError: onError === undefined ? defaultErrorHandler : onError,
toJSON: function(key: string, value: ReactModel): ReactJSONValue {
Expand Down

0 comments on commit 2c4a074

Please sign in to comment.