react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Luxon causes crash in 0.81.2

Open SBS-randerson opened this issue 9 months ago • 1 comments

Problem Description

Calling any Luxon function in react native windows causes the app to crash. The app builds fine and crashes when a Luxon function is called.

Steps To Reproduce

Install luxon 3.7.2 (also tried a few other 3.x and 2.x versions)

import {DateTime} from 'luxon';
DateTime.now()

App crashes with no error messages

Expected Results

No response

CLI version

20.0.0

Environment

System:
  OS: Windows 11 10.0.26100
  CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
  Memory: 3.12 GB / 15.73 GB
Binaries:
  Node:
    version: 22.22.0
    path: C:\nvm4w\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 10.9.4
    path: C:\nvm4w\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.22621.0
      - 10.0.26100.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 16.11.36631.11 (Visual Studio Professional 2019)
    - 17.14.36930.0 (Visual Studio Enterprise 2022)
Languages:
  Java:
    version: 21.0.9
    path: C:\Program Files\Eclipse Adoptium\jdk-21.0.9.10-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.4
    wanted: 19.1.4
  react-native:
    installed: 0.81.5
    wanted: 0.81.5
  react-native-windows:
    installed: 0.81.2
    wanted: 0.81.2
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Community Modules

"i18next": "^25.8.11", "lodash": "^4.17.23", "luxon": "3.4.4", "react": "19.1.4", "react-i18next": "^16.5.4", "react-native": "0.81.5", "react-native-collapsible": "^1.6.1", "react-native-elements": "^3.4.3", "react-native-macos": "0.81.2", "react-native-safe-area-context": "^5.5.2", "react-native-windows": "0.81.2", "socket.io-client": "^4.8.1" "@testing-library/react-native": "^13.3.3", "@react-native-async-storage/async-storage": "^2.2.0", "@react-native-documents/picker": "^12.0.1", "@react-native/new-app-screen": "0.81.2",

I'm aware some of these may not be compatible with RNW 0.81, I'm in the processing of updating them.

Target React Native Architecture

New Architecture (WinAppSDK) Only

Target Platform Version

= 10.0.26100

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

SBS-randerson avatar Feb 20 '26 05:02 SBS-randerson

Fixed the issue with a polyfill.

Added the following dependencies:

"@formatjs/intl-datetimeformat": "^7.2.2",
"@formatjs/intl-getcanonicallocales": "^3.2.1",
"@formatjs/intl-locale": "^5.2.1",
"@formatjs/intl-numberformat": "^9.2.2",
"@formatjs/intl-pluralrules": "^6.2.2",

Added to the index.js:

// Polyfill Intl APIs for luxon
import "@formatjs/intl-getcanonicallocales/polyfill";
import "@formatjs/intl-locale/polyfill";
import "@formatjs/intl-pluralrules/polyfill";
import "@formatjs/intl-pluralrules/locale-data/en"; // Import locale data for English
import "@formatjs/intl-datetimeformat/polyfill";
import "@formatjs/intl-datetimeformat/locale-data/en"; // Import locale data for English
import "@formatjs/intl-numberformat/polyfill";
import "@formatjs/intl-numberformat/locale-data/en"; // Import locale data for English

I thought intl was already included by react-native?

SBS-randerson avatar Feb 24 '26 19:02 SBS-randerson