Skip to content

Commit cd91cee

Browse files
authored
fix(react-router): prevent webpack static analysis of React.use with let binding (#7182)
1 parent c19571f commit cd91cee

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/react-router': patch
3+
---
4+
5+
fix(react-router): prevent webpack static analysis of `React.use` with let binding

packages/react-router/src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import * as React from 'react'
55
// React 18 with Webpack, which statically analyzes imports and fails when it
66
// sees React.use referenced (since 'use' is not exported from React 18).
77
// This uses a dynamic string lookup to avoid the static analysis.
8-
const REACT_USE = 'use'
8+
// eslint-disable-next-line prefer-const -- Must be `let` to prevent bundler constant-folding
9+
let REACT_USE = 'use'
910

1011
/**
1112
* React.use if available (React 19+), undefined otherwise.

0 commit comments

Comments
 (0)