-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Add support for preload media to ReactDOM #28635
Conversation
614dea8
to
e8bcaa8
Compare
e8bcaa8
to
281a48c
Compare
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.
TY
This PR adds support for `media` option to `ReactDOM.preload()`, which is needed when images differ between screen sizes (for example mobile vs desktop)
This feature is still not available for react-dom 18.3.1. Will it be part of the 19's updates? |
These new APIs are part of the React 19 release and will not be available on any 18.x release. React 19 was originally intended to be released shortly after React conf but we decided to include a change to sibling rendering which has not landed yet but should soon |
Can we have this released in 18? It's a fully backward compatible change |
Looks like 'media' has not been added to the PreloadOption type on "@types/react-dom@19.0.2". preload(
"https://src",
{
as: "image",
fetchPriority: "high",
imageSizes: "100vw",
imageSrcSet: "https://srcest",
type: "image/webp",
...{ media: "screen and (orientation: portrait)" },
}
) |
Summary
This PR adds support for
media
option toReactDOM.preload()
, which is needed when images differ between screen sizes (for example mobile vs desktop).Tests copied from #27129 (thanks @damnsamn!)
How did you test this change?
Ran the tests from #27129 before:
After: