Skip to content

Fix RTL on a web runtime that swaps sides, and run the example on @rootnative/web - #5

Open
raajnadar wants to merge 2 commits into
mainfrom
chore/example-on-rootnative-web
Open

raajnadar wants to merge 2 commits into
mainfrom
chore/example-on-rootnative-web

Conversation

@raajnadar

@raajnadar raajnadar commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

This PR has two changes. Keep it open for more tests before a merge.

1. The RTL fix (7e77103)

Some components mirror a physical side (left, a corner) by hand on the web in RTL, because react-native-web keeps the sides physical. A web runtime that swaps left and right itself then flipped them two times: the Slider filled from the wrong side, and the LinearProgress, Tabs, ButtonGroup, and Carousel had the same fault.

  • One rule in @rootnative/utils: swapsLeftAndRight() reads I18nManager.doLeftAndRightSwapInRTL on the web too, and webKeepsPhysicalSides() replaces each "web and RTL" check.
  • New exports of @rootnative/utils: swapsLeftAndRight and webKeepsPhysicalSides. The registry has both names.
  • On react-native-web and on native, nothing changes.
  • Tests: rtl-swap.web.test.tsx (15 cases) and 4 native cases in utils.

2. The example on @rootnative/web (53bcf29)

On the web, the example app now runs on @rootnative/web 0.0.3 in place of react-native-web. withRootNative in the Metro config sends each react-native and react-native-web import to @rootnative/web-expo. react-native-web 0.21.4 stays in the root tree for the web Jest projects of the packages.

Checked

  • All 43 routes render on the Expo dev server in headless Chromium, with no console error or warning.
  • No route bundle has a module of react-native-web.
  • Benchmark of two production exports from one tree, 10 runs, 4x CPU throttle:
    • The HTML of the export is 49 % smaller.
    • Script time at load is 12 to 17 % lower on each of 7 routes.
    • 83 to 100 % fewer elements carry an inline style, and each route has about half the CSS rules.
    • Typing in a text field takes 39 % less script time.

Open before a merge

  • CI on 53bcf29: "Validate" passes, with the static export check (48 pages pass the audit and load clean in Chrome) and the server export check (47 pages).
  • Presses and overlays on each route.
  • RTL on each route with withRootNative and the RTL fix.
  • Three numbers that got worse, traced:
    • Button presses, task time: a fault of the test, not of the runtime. A button of the page intro opened the docs site in a new tab during the run. Without it, the task time is equal (1,035 against 1,028 ms).
    • Button presses and the menu, style recalc (+43 % and +81 %): on @rootnative/web, a press plays the corner morph (28 border-radius steps in about 430 ms) and 11 steps of the state layer color. On react-native-web, the same click writes 4 color steps in 50 ms and no border-radius step. So the extra style work is animation that react-native-web doesn't show. Not compared with iOS or Android yet.
    • /text-field load, style recalc: one more recalc of the full document (319 elements, 18 ms at 4x), from createSheet of @rootnative/web-expo. The server HTML of a static export doesn't have the reset sheet, so the client inserts it first in head. It happens on each route. A fix belongs in @rootnative/web-expo.
  • The menu cycle also adds 15 CSS rules against 5: a new dynamic style value inserts a rule during an interaction.
  • One server-side React warning on /i18n (hreflang), not yet compared with react-native-web.
  • A CHANGELOG line for the RTL fix at the next release.

@raajnadar raajnadar changed the title Run the example on @rootnative/web Fix RTL on a web runtime that swaps sides, and run the example on @rootnative/web Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant