Closed
Description
Which project does this relate to?
Router
Describe the bug
Minimal reproduction:
const NumberContext = createContext<number>()
function Reproduction() {
return (
<NumberContext.Provider value={123}>
<Link >
<Button />
</Link>
</NumberContext.Provider>
)
}
function Button() {
const context = useContext(NumberContext)
if (!context) {
throw new Error("No context")
}
return <button onClick={() => console.log("Context value", context)}>Print</button>
}
When I click the button it shows:
Context value 123
computations created outside a `createRoot` or `render` will never be disposed
Uncaught Error: No context
Obviously, Link
gets children outside of createRoot.
If I comment out useLinkProps, everything works fine. So I think the issue is in the useLinkProps
function.
Your Example Website or App
https://stackblitz.com/edit/github-1deax8jh?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
Click Print
Expected behavior
No error throws
Screenshots or Videos
No response
Platform
- OS: Windows
- Browser: Chrome
- Version: 136.0.7103.93
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels