Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changepacks/changepack_log_metro_viewport_motion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"changes": {
"packages/metro-plugin/package.json": "Patch"
},
"note": "Compile `vw`/`vh`/`vmin`/`vmax` (and their small, large and dynamic forms) to one multiplication of the window size, and `_motionReduce`/`_motionSafe` to the system's reduced-motion setting, on React Native.",
"date": "2026-11-22T00:00:00.000Z"
}
7 changes: 7 additions & 0 deletions .changepacks/changepack_log_react_native_viewport_motion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"changes": {
"packages/react/package.json": "Patch"
},
"note": "The React Native runtime adds `useReducedMotion` (from `AccessibilityInfo`), `useWindowWidth`, `useWindowHeight` and the `Sized` wrapper, for `_motionReduce`/`_motionSafe` and viewport lengths. Window changes now notify every hook, and React renders again only the components whose value changed. The runtime grows from 1,185 B to 1,302 B min+gzip.",
"date": "2026-11-22T00:00:00.000Z"
}
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
- feat/react-native-compat
- feat/react-native-web
- feat/react-native-types
- feat/react-native-docs

# Pull requests and every job below run read-only. Only the `release` and
# `deploy-pages` jobs get write permissions, and they run on pushes to main
Expand Down
23 changes: 19 additions & 4 deletions apps/expo/check-bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ import { join } from 'node:path'
const PLACEHOLDER = 'Cannot run on the runtime'
/** Names of the runtime that only code using it holds, as minified code keeps them */
const RUNTIME_NAMES =
/\b(?:defineThemes|useThemeIndex|useBreakpoint|useLandscape|Focused)\b/g
/\b(?:defineThemes|useThemeIndex|useBreakpoint|useLandscape|useReducedMotion|useWindowWidth|useWindowHeight|Focused)\b/g
/** What src/App.tsx must use from the runtime */
const APP_HOOKS = ['useThemeIndex', 'useBreakpoint', 'useLandscape', 'Focused']
const APP_HOOKS = [
'useThemeIndex',
'useBreakpoint',
'useLandscape',
'useReducedMotion',
'useWindowHeight',
'Focused',
]
/** Modules of @devup-ui/react, by the path Metro resolves */
const REACT_PACKAGE = /(^|[\\/])(@devup-ui[\\/]react|packages[\\/]react)[\\/]/
/**
Expand Down Expand Up @@ -99,13 +106,21 @@ function mapSources(map) {
: map.sources
}

/** Each name of the runtime, with the sources of the code that names it */
/**
* Each name of the runtime, with the sources of the app that name it: a
* package may name its own hook the same (Reanimated's `useReducedMotion`)
*/
function runtimeUsers(code, locate) {
const users = new Map()
code.split('\n').forEach((line, index) => {
for (const match of line.matchAll(RUNTIME_NAMES)) {
const source = locate(index, match.index)
if (source === null || NATIVE_RUNTIME.test(source)) continue
if (
source === null ||
NATIVE_RUNTIME.test(source) ||
/[\\/]node_modules[\\/]/.test(source)
)
continue
const sources = users.get(match[0]) ?? new Set()
sources.add(source)
users.set(match[0], sources)
Expand Down
8 changes: 7 additions & 1 deletion apps/expo/check-web.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Opens the web export (`expo export --platform web` wrote dist/) in Chromium
// and checks that react-native-web renders the styles Devup UI compiled: the
// card takes the theme's color and switches with the theme, the input takes
// card takes the theme's color and switches with the theme and is at least
// 30vh tall, the input takes
// its focus style through the runtime's `Focused`, and the button, a
// `Pressable`, counts a press.
import { createReadStream, existsSync, statSync } from 'node:fs'
Expand Down Expand Up @@ -66,6 +67,11 @@ try {
'rgb(255, 255, 255)',
'the card in the light theme',
)
expectEqual(
await style(card, 'minHeight'),
`${(await page.evaluate(() => window.innerHeight)) * 0.3}px`,
'the card, at least 30vh tall',
)
expectEqual(
await style(count, 'backgroundColor'),
'rgb(90, 68, 255)',
Expand Down
8 changes: 7 additions & 1 deletion apps/expo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ export function App() {
borderRadius="$radius"
boxShadow="$raised"
maxW={[null, null, '480px']}
minH="30vh"
p={[4, null, 6]}
testID="card"
w="100%"
>
<Text color="$muted" fontSize="14px" mb={2}>
<Text
_motionReduce={{ fontStyle: 'italic' }}
color="$muted"
fontSize="14px"
mb={2}
>
Your name
</Text>
<Input
Expand Down
5 changes: 3 additions & 2 deletions apps/landing/src/app/(detail)/docs/react-native/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ things work differently.
| | Web | React Native |
| ------------------------------------------ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Output | Atomic CSS classes in a stylesheet | Style objects in one `StyleSheet.create` per file |
| Runtime | None | None for static styles. A small runtime (about 1.2 kB gzip) reads the theme, the window and press, hover and focus states, but only for the styles that use them. With `runtime: false`, those styles are build errors instead. |
| Runtime | None | None for static styles. A small runtime (about 1.3 kB gzip) reads the theme, the window, reduced motion and the focus of inputs, but only for the styles that use them. With `runtime: false`, those styles are build errors instead. |
| Numbers | `p={4}` is `16px` | `p={4}` is `16`: density-independent pixels, with the same scale as the web |
| Units | Any CSS unit | Pixels, `rem` and `em` (16 pixels each), percentages and `auto`. `vw`, `vh` and other units are build errors. |
| Units | Any CSS unit | Pixels, `rem` and `em` (16 pixels each), percentages and `auto`. `vw`, `vh`, `vmin` and `vmax` become one multiplication of the window's size, and only components using them render again on a resize. |
| Themes | CSS variables, switched by `data-theme` | The runtime picks the style object of the current theme. `setTheme`, `useTheme` and `getTheme` work, and the system appearance picks `light` or `dark`. |
| Breakpoints | Media queries | The window width, with the `breakpoints` of devup.json. A component renders again only when the window crosses into another breakpoint. |
| `_active`, `_hover`, `_focus`, `_disabled` | CSS pseudo-classes | `Pressable` tells its style function whether it is pressed, hovered or focused: a `Button` is one, and a `Box` with these styles becomes one. `_focus` on an `Input` works through the runtime. `_disabled` reads the `disabled` prop. Hover and focus happen only where there is a pointer or keyboard focus, such as the web. |
| Other selectors | `_before`, `_focusVisible`, `selectors`, ... | Build errors: React Native has no selectors |
| `_ios`, `_android`, `_web` | — | Apply on that platform only |
| `_portrait`, `_landscape` | Media queries | The window's orientation |
| `_motionReduce`, `_motionSafe` | `prefers-reduced-motion` media queries | Whether the system asks apps to reduce motion (`AccessibilityInfo`) |
| `className={css(...)}` | A class | The build turns it into the element's styles |
| `keyframes`, `animation*`, `transition*` | CSS animations | [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/): an element that animates renders Reanimated's animated component. Without Reanimated installed, these are build errors. |
| `globalCss`, `Grid` | Supported | Build errors |
Expand Down
Loading
Loading