microsoft/reactxp

React-Native 60, 61, 62 - Compatibility Issues with reactxp 2.0.0

fbartho opened this issue · 4 comments

When upgrading from react-native 0.59 to 0.62 we discovered some breaking API changes that make ReactXP fail to load!

Issue 1: AccessibilityInfo

In react-native 0.60, a breaking change was introduced that deleted the fetch() API and added helpers for granular AccessibilitySettings.

0.59 AccessibilityInfo Docs
0.60 AccessibilityInfo Docs

This manifests in an error on import of "reactxp":

 Test suite failed to run

    TypeError: Cannot read property 'then' of undefined

       8 |  */
       9 | import React from "react";
    > 10 | import * as RX from "reactxp";
         | ^
      11 | 
      12 | export { IntlShape } from "react-intl";
      13 | import {

      at new Accessibility (node_modules/reactxp/dist/native-common/Accessibility.js:41:56)

I think there's a workaround for jest here, of defining fetch() in client-side code.

That however does mean that this API needs significant updates for react-native 0.6* support!

I am successfully using react-native 0.61, 0.62 is not released yet but I am not expecting a problem?

See Discussion and PR here #1126 - which would forward-port to the new API but impacts backwards-compatibility and is not strictly required for reactxp v2 to work with react-native 0.61.5 at least

@mikehardy I tested it yesterday on 0.62 and the fetch method wasn’t present (at runtime, at least in jest), so we have to do something. Either detect the new methods and use that, and fallback to fetch for older RN?

I’ll cross post this to the PR, thanks for pointing it out to me!

Fetch should still be present, it is just a warning now. The types should still have it or they are wrong, IMHO:

https://reactnative.dev/blog/2020/03/26/version-0.62#other-improvements

facebook/react-native@523ab83