I am trying to try out new features of React 19.
In order to do that, I have created React app with Vite and TypeScript:
npm create vite@latest
Then upgraded to React 19 libraries (accoridngly to this article):
npm install --save-exact react@rc react-dom@rc
After this I can see upgraded React version in package.json:
"dependencies": {
"react": "19.0.0-rc-d8c90fa4-20241001",
"react-dom": "19.0.0-rc-d8c90fa4-20241001"
}
Now I want to try out new React 19 features, one of which is new hook use
, but when I try:
import { use } from 'react'
I get an error that it's not exported from react
:
Module "react" has no exported member 'use'
Obviously, I did now complete correctly "migration" to React 19 - what did I miss? How to make it work?
I also have suspicion that this feature might be specific to React Server Components..
The @types/react
you're using don't yet have that name, so TypeScript is confused.
You could try a local module augmentation file (e.g. src/react-19.d.ts
):
/// <reference types="react" />
declare namespace React {
export function use(): void; // fill in with the correct signature
}