Skip to content

fix: review corrections before 1.6.0 - #26

Merged
mz-real merged 1 commit into
masterfrom
fix/pre-1.6.0-review
Sep 25, 2026
Merged

mz-real merged 1 commit into
masterfrom
fix/pre-1.6.0-review

Conversation

@mz-real

@mz-real mz-real commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Fixes from an independent review of the unreleased 1.6.0 batch (#22, #23, #24).

Summary

  • ssr flashed initialWindow on later mounts and on native:
    • A module-level hasHydrated flag, set in the first ssr provider's effect, means providers mounted afterwards (screens, modals, client-side navigation) render the real window at once. Effects never run on the server.
    • ssr is ignored when Platform.OS !== 'web', so one Expo Router root layout can enable it safely.
    • StrictMode double effects settle correctly.
  • Dual-package hazard: ResponsiveProvider's and MockWindowProvider's contexts are now realm-wide singletons (Symbol.for on globalThis). Before, an app that loaded both the ESM and CJS builds (for example a CJS dependency plus an ESM story) got two contexts, and the override silently did nothing. This is written without ??= for older Babel presets.
  • @deprecated restored: removeOrientationListener regains its tag in the published .d.ts. The legacy removeEventListener is called as a method again, which keeps this bound.
  • Softer production fallback: ssr without initialWindow now drops only the ssr flag and keeps the rest of the config, instead of discarding everything.
  • Docs: the README and CHANGELOG cover ssr scope (web, first hydration, hook output only, nested providers must repeat it) and MockWindowProvider limits.

Test plan

  • npm test: 140/140, 100% coverage. New tests cover a late-mounted provider, native being ignored, StrictMode, the prod ssr-only fallback, and a shared context across isolated module copies.
  • npm run lint, typecheck, build; the .d.ts shows @deprecated again

- ssr: web only, and only for the first hydration -- a module-level flag
  lets providers mounted later render the real window immediately, and
  native ignores ssr. StrictMode-safe. In production an invalid ssr flag
  is dropped while the rest of the config is kept.
- Contexts are realm-wide singletons (Symbol.for on globalThis), so
  MockWindowProvider and ResponsiveProvider work when an app loads both
  the ESM and CommonJS builds.
- removeOrientationListener regains its @deprecated JSDoc in the .d.ts;
  the legacy removeEventListener is called as a method again.
- Docs: ssr scope and nesting, MockWindowProvider limits, CHANGELOG.
@mz-real
mz-real merged commit f84bd0b into master Sep 25, 2026
5 checks passed
@mz-real
mz-real deleted the fix/pre-1.6.0-review branch September 25, 2026 21:43
@mz-real mz-real mentioned this pull request Sep 25, 2026
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