-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
refactor: update react types to v19 #14241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,7 +270,7 @@ export interface RouterProviderProps { | |
* - If you are rendering in a non-DOM environment, you can import | ||
* `RouterProvider` from `react-router` and ignore this prop | ||
*/ | ||
flushSync?: (fn: () => unknown) => undefined; | ||
flushSync?: <R>(fn: () => R) => R; | ||
/** | ||
* An error handler function that will be called for any loader/action/render | ||
* errors that are encountered in your application. This is useful for | ||
|
@@ -654,7 +654,7 @@ export function MemoryRouter({ | |
initialEntries, | ||
initialIndex, | ||
}: MemoryRouterProps): React.ReactElement { | ||
let historyRef = React.useRef<MemoryHistory>(); | ||
let historyRef = React.useRef<MemoryHistory>(undefined); | ||
if (historyRef.current == null) { | ||
historyRef.current = createMemoryHistory({ | ||
initialEntries, | ||
|
@@ -1541,8 +1541,8 @@ export function createRoutesFromChildren( | |
): RouteObject[] { | ||
let routes: RouteObject[] = []; | ||
|
||
React.Children.forEach(children, (element, index) => { | ||
if (!React.isValidElement(element)) { | ||
React.Children.forEach<any>(children, (element, index) => { | ||
if (!React.isValidElement<any>(element)) { | ||
Comment on lines
+1544
to
+1545
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is related to the breaking change of the default generic from |
||
// Ignore non-elements. This allows people to more easily inline | ||
// conditionals in their route config. | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what changed but otherwise the typecheck here fails
react-router/packages/react-router/lib/rsc/browser.tsx
Line 817 in ed849c8
I updated a type to align with
ReactDOM.flushSync
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f2116ac0a107a3a2ac757c78347aa3a59c27e848/types/react-dom/index.d.ts#L17