Skip to content

feat: add support for react-native 0.81#3114

Merged
kkafar merged 11 commits into
mainfrom
@kligarski/bump-to-0.81.0-rc.2
Aug 12, 2025
Merged

feat: add support for react-native 0.81#3114
kkafar merged 11 commits into
mainfrom
@kligarski/bump-to-0.81.0-rc.2

Conversation

@kligarski

@kligarski kligarski commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Description

Adds support for react-native@0.81.

Closes https://github.com/software-mansion/react-native-screens-labs/issues/357.

Changes

Test code and steps to reproduce

Run example apps.

Checklist

  • Ensured that CI passes

@kligarski kligarski force-pushed the @kligarski/bump-to-0.81.0-rc.2 branch 2 times, most recently from 7b1b029 to a0a5cff Compare August 11, 2025 09:06
@kligarski

Copy link
Copy Markdown
Contributor Author

Not sure if we can satifly linter without using new imports for codegenNativeComponent (0.80.0) and ImageSource (0.81.0) which would break compatibility with older react-native versions.

@kkafar kkafar marked this pull request as ready for review August 11, 2025 10:26
…ops` by setting `RN_SERIALIZABLE_STATE` compile flag (#3117)

## Description

The function has been introduced with RN 0.80 and later modified in
react/react-native@c059ae1b77.

The #c059ae1b77 added RN_SERIALIZABLE_STATE compile time definition,
which helps to resolve an ridiculous crash / hang we had. To give some
context - the crash occured in codegened C++ code in
`RNSScreenProps::~RNSScreenProps` (yes, this is a compiler generated
default dtor) or in other dtors, depending on exact timing. It is still
unknown exactly what was the error mechanism, but most likely due to
some timing / concurrency related issues dtor attempted to free some
memory that was no longer mapped to a process or something. Anyway,
setting this flag resolves the problem.

Additionally, this is also a way-to-go in terms of setting compile
options required by RN since 0.80.


## Test code and steps to reproduce

<details>

<summary>Crash reproduction setup</summary>

```tsx

import React from 'react';
import { useState } from 'react';
import { Button } from 'react-native';
import { ScreenStack, ScreenStackItem } from 'react-native-screens';

export default function BasicBareScreens() {
  const [secondShown, setSecondShown] = useState(false);

  return (
    <ScreenStack>
      <ScreenStackItem screenId="1" activityState={2}>
        <Button title="Go to screen 2" onPress={() => setSecondShown(true)} />
      </ScreenStackItem>
      {secondShown && (
        <ScreenStackItem screenId="2" activityState={2}>
          <Button title="Go back" onPress={() => setSecondShown(false)} />
        </ScreenStackItem>
      )}
    </ScreenStack>
  );
}

```

</details>

## Checklist

- [x] Included code example that can be used to test this change
- [ ] Ensured that CI passes

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have single question regarding new edgeToEdge option.

Comment on lines +46 to +49
# Use this property to enable edge-to-edge display support.
# This allows your app to draw behind system bars for an immersive UI.
# Note: Only works with ReactActivity and should not be used with custom Activity.
edgeToEdgeEnabled=true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check what this is doing.

Currently we detect whether the edgeToEdge is enabled or not by using react-native-is-edge-to-edge package. Will this conflict? What if we set edgeToEdgeEnabled=false here & we have react-native-edge-to-edge installed? What happens? What is the interaction here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add comment here, that we do not support this yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created a separate PR with changes related to new edge to edge API: #3121

## Description


This resolves linter issues in native component specs, which we can not
really fix.


Basically the issue is as follows:

<img width="1764" height="107" alt="image"
src="https://github.com/user-attachments/assets/efe3f8dc-c205-40ba-af4f-904dd6a8b59a"
/>


## Test code and steps to reproduce

Lint CI should pass.

## Checklist

- [ ] Ensured that CI passes
@kkafar

kkafar commented Aug 11, 2025

Copy link
Copy Markdown
Member

We did a quick research together with @kligarski about current situation with edge to edge support.

react/react-native@09ef774 introduced support for detecting whether app is in edge to edge in RN core. This API is available since 0.81. Therefore, while we support older versions we should keep support for react-native-edge-to-edge package, then we can migrate to this new API.

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I've added single request to add comment & we will want to land the solution for https://github.com/software-mansion/react-native-screens-labs/issues/357

Comment on lines +46 to +49
# Use this property to enable edge-to-edge display support.
# This allows your app to draw behind system bars for an immersive UI.
# Note: Only works with ReactActivity and should not be used with custom Activity.
edgeToEdgeEnabled=true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add comment here, that we do not support this yet.

@kkafar kkafar mentioned this pull request Aug 11, 2025
8 tasks

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're looking good.

kligarski and others added 3 commits August 12, 2025 10:59
## Description

Adds support for `react-native`'s `edgeToEdgeEnabled` property.

Closes
software-mansion/react-native-screens-labs#357.

## Changes

- rename `EdgeToEdgePackageDetector` to `EdgeToEdgeDetector`
- make `EdgeToEdgeDetector` use different implementation for RN < 0.81
and RN >= 0.81
- use new edgeToEdgeEnabled and isEdgeToEdgeFeatureFlagOn
- add clarifying comments

## Test code and steps to reproduce

N/A

## Checklist

- [ ] Ensured that CI passes
…faceView` (#3122)

## Description

`TabsHost.id` collied with `ReactSurfaceView.id`, because RN 0.81
started to number the root views from 1, instead of 11 as it was before.
This caused issues, becuase `FragmentTransaction.add(containerViewId:
Int, ...)` requires us to pass the `containerViewId`, which it then uses
to find a view in hierarchy with that id & it mounts added fragment's
view there. If collision occurs, Android Framework mounts the fragment
directly under `ReactSurfaceView` instead of our `TabsHost`.

Proposed workaround does the following:

1. ~it passes int value of react native minor version down from gradle
   script to build config, so that it is accessible in platform code.
   AFAIK there is no dedicated API as of 0.81 for this, therefore we
need a workaround.~ We start counting from 3, it should work no matter
RN version.
2. It adds new `ViewIdGenerator` that implements new `ViewIdProviding`.
   It has capability of overriding the view generator, so that the lib
   can be integrated in brownfield scenarios. We should use this object
   to generate view id for any of our views that need it.
3. The `ViewIdGenerator` relies on internals of RN, that are referenced
   in the code comments, to provide non-colliding view ids (tags).


## Test code and steps to reproduce

`TestBottomTabs` should work on 0.81. W/o this patch you won't see the
bottom tab bar (it will be rendered, but under the top screen. The view
would be mounted directly under `ReactSurfaceView`.

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
@kkafar kkafar merged commit 395ca94 into main Aug 12, 2025
8 checks passed
@kkafar kkafar deleted the @kligarski/bump-to-0.81.0-rc.2 branch August 12, 2025 17:52
Flewp pushed a commit to discord/react-native-screens that referenced this pull request Oct 16, 2025
…ified for 4.11.1

Adds support for `react-native@0.81`.

Closes
https://github.com/software-mansion/react-native-screens-labs/issues/357.

- apply updates from upgrade-helper
- set `edgeToEdgeEnabled=true` (might require changes to how we detect
edge-to-edge)
- changed imports from `metro-config` to use `private` alias
(react/metro#1530)
- changed deprecated `ShadowNode::Shared` to `std::shared_ptr<const
ShadowNode>` (react/react-native#52393)
- bump `react-native-gesture-handler`, `react-native-safe-area-context`
- software-mansion#3117
- software-mansion#3122

Run example apps.

- [ ] Ensured that CI passes

---------

Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
Co-authored-by: Kacper Kafara <kacperkafara@gmail.com>
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.

2 participants