Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ciffelia committed Jan 26, 2023
1 parent e8d8877 commit 6ea3ff8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@react-aria/ssr/src/SSRProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export type SSRIdOptions =

const SSRIdOptionContext = React.createContext<SSRIdOptions>({mode: 'counter'});

let canUseDOM = Boolean(
const canUseDOM = Boolean(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
Expand All @@ -94,7 +94,7 @@ export function SSRProvider({children, ...idOption}: SSRProviderProps): JSX.Elem
let cur = useContext(SSRContext);
let value: SSRContextValue = useMemo(() => {
// If React strict mode is enabled, the function passed to `useMemo` will be called twice on the client.
// As a result, `ctx.current` will increase by two on the client side, causing hydration errors.
// As a result, `cur.current` will increase by two on the client side, causing hydration errors.
// To avoid the error, we increase the counter to mimic this behavior on the server side.
if (idOption.strictMode && !canUseDOM) {
cur.current++;
Expand Down

0 comments on commit 6ea3ff8

Please sign in to comment.