Skip to content

Commit 0ca8420

Browse files
authored
[Flight] Use valid CSS selectors in useId format (#33099)
1 parent 0db8db1 commit 0ca8420

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,8 @@ describe('ReactFlight', () => {
19571957
});
19581958
expect(ReactNoop).toMatchRenderedOutput(
19591959
<>
1960-
<div prop=":S1:" />
1961-
<div prop=":S2:" />
1960+
<div prop="«S1»" />
1961+
<div prop="«S2»" />
19621962
</>,
19631963
);
19641964
});
@@ -1981,8 +1981,8 @@ describe('ReactFlight', () => {
19811981
});
19821982
expect(ReactNoop).toMatchRenderedOutput(
19831983
<>
1984-
<div prop=":fooS1:" />
1985-
<div prop=":fooS2:" />
1984+
<div prop="«fooS1»" />
1985+
<div prop="«fooS2»" />
19861986
</>,
19871987
);
19881988
});
@@ -2021,8 +2021,8 @@ describe('ReactFlight', () => {
20212021
assertLog(['ClientDoubler']);
20222022
expect(ReactNoop).toMatchRenderedOutput(
20232023
<>
2024-
<div prop=":S1:">:S1:</div>
2025-
<div prop=":S1:">:S1:</div>
2024+
<div prop="«S1»">«S1»</div>
2025+
<div prop="«S1»">«S1»</div>
20262026
</>,
20272027
);
20282028
});

packages/react-server/src/ReactFlightHooks.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ function useId(): string {
120120
}
121121
const id = currentRequest.identifierCount++;
122122
// use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
123-
return ':' + currentRequest.identifierPrefix + 'S' + id.toString(32) + ':';
123+
return (
124+
'\u00AB' +
125+
currentRequest.identifierPrefix +
126+
'S' +
127+
id.toString(32) +
128+
'\u00BB'
129+
);
124130
}
125131

126132
function use<T>(usable: Usable<T>): T {

0 commit comments

Comments
 (0)