Commit Graph

122 Commits

Author SHA1 Message Date
Rubén Norte a16c6c9477 Add feature flag to enable Web Performance APIs by default (#53547)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53547

Changelog: [internal]

This creates a new feature flag to enable the modern Web performance APIs in RN by default. It's disabled by default so it shouldn't have any effect at the moment.

Reviewed By: rshest

Differential Revision: D80811430

fbshipit-source-id: 47d5fd12ac8809aa3c5ad37cdd31c0d9e3ed5912
2025-09-09 08:07:31 -07:00
Sam Zhou cf664c65e2 Standardize subtyping error code into incompatible-type in react native and metro (#53312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53312

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D80400976

fbshipit-source-id: 196af69c0b9621b2a2675b232406639773e04933
2025-08-18 09:04:31 -07:00
Dawid Małecki fb4587780e Move ReactNativeFeatureFlags to src/private (#52610)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52610

This diff removes `ReactNativeFeatureFlags` from `react-native/Libraries/ReactNative` and migrates
`shouldPressibilityUseW3CPointerEventsForHover` to common `ReactNativeFeatureFlags` in `src/private/featureflags`. The `shouldEmitW3CPointerEvents is removed as it is used in `rn-tester` to hide some examples.

Changelog:
[General][Breaking] - Migrate `shouldPressibilityUseW3CPointerEventsForHover` to common private feature flags and remove `shouldEmitW3CPointerEvents` flag.

Reviewed By: robhogan

Differential Revision: D75448698

fbshipit-source-id: 03942c9504b855f2054c9a5948c0521ce17365b5
2025-07-23 01:43:05 -07:00
Nicola Corti 59101d6809 Remove unnecessary OSSLibraryExample (#52705)
Summary:
This module is currently unused, so we can clean it up.

## Changelog:

[INTERNAL] -

Pull Request resolved: https://github.com/facebook/react-native/pull/52705

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D78555763

Pulled By: cortinico

fbshipit-source-id: 0a6152ab3d357cac0c6d7669f292680af7b87074
2025-07-22 03:16:48 -07:00
Peter Abbondanzo fe66694faf Add example for focus events on Android (#51725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51725

This change builds upon the focus/blur portion showcased in ViewExample but showcases several more components all in one spot. This can be shared with additional platforms or expanded to include more component examples like Image, but the goal is to target Android and not distract from the primary use cases.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D75747410

fbshipit-source-id: 7d53366d9f32192ca6b3da45dd127836fb6efdf6
2025-06-05 13:48:50 -07:00
Tim Yung 3e6423fe65 RN: Flowify packages/rn-tester (#51788)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51788

Adds `flow` to the remaining files that are lacking it in the `packages/rn-tester` directory.

This also adds any necessary type annotations and fixes lint warnings.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D75899307

fbshipit-source-id: 27a74ed0007b3b754446a45931c2c148312d5e3a
2025-06-04 12:03:52 -07:00
Dawid Małecki 9cdd0db138 Remove JSEventLoopWatchdog from react-native package (#51614)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51614

`JSEventLoopWatchdog` is not used in react-native package. This diff moves it to rn-tester which previously deep imported it from react-native (which we want to avoid).

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D75410548

fbshipit-source-id: d4996742578e3b068e7acad9479394388b1907ac
2025-05-27 03:10:14 -07:00
Tim Yung 1977dd6596 RN: Sort Pragmas in Headers (#51554)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51554

Sorts pragma directives file headers in React Native.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D75264593

fbshipit-source-id: 9e4b253dd0fc94dc2fc469d7114b93a8aae305f4
2025-05-22 21:18:53 -07:00
Panos Vekris 50ca7e5730 manual annotations in preparation of natural inference rollout in react-native, tools, etc.
Summary:
The Flow team is improving the way Flow infers type for primitive literals. This diff prepares the codebase for the new behavior by adding type annotations, or annotations of the form `'abc' as const`.

Changelog: [internal]

Reviewed By: marcoww6

Differential Revision: D75188179

fbshipit-source-id: be50990f23f79cf2d8dae7576af5190218adcafe
2025-05-21 20:06:46 -07:00
Panos Vekris 1eebb5aa11 Back out "add 'as const' annotations in preparation of natural inference rollout in xplat/js [4/n]"
Summary:
Original commit changeset: 67ee5673816d

Original Phabricator Diff: D75114154

Reviewed By: SamChou19815

Differential Revision: D75161840

fbshipit-source-id: 144fc0e488154b957f4f2a549c077a2784124849
2025-05-21 12:03:51 -07:00
Panos Vekris 2a068c6559 add 'as const' annotations in preparation of natural inference rollout in xplat/js [4/n] (#51488)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51488

The Flow team is improving the way Flow infers type for primitive literals.
Announcement: https://fb.workplace.com/groups/flowlang/permalink/1725180268087629/

This diff prepares the codebase for the new behavior by codemoding `as const` annotations.

## Repro steps

1/ Used steps in D73610163 to produce the code changes.

2/ Reverted files where `flow` errored:
```
flow status --show-all-errors > errors.log
node ~/fbsource/fbcode/flow/facebook/error-analyzer.js errors.log |
  awk -F':' '{ print $1 }' | sort -u | grep -v 'Total Error Count' |
  xargs hg revert --rev .
```

3/ Reverted files that did not improve error count in new Flow mode
```
# Run Flow before change
~/fbsource/fbcode/flow/facebook/flowd status --show-all-errors > errors-0.log
# Run Flow after change
~/fbsource/fbcode/flow/facebook/flowd status --show-all-errors > errors-1.log

# Compute error counts before and after
node ~/fbsource/fbcode/flow/facebook/error-analyzer.js errors-0.log | sort > errors-counts-0.log
node ~/fbsource/fbcode/flow/facebook/error-analyzer.js errors-1.log | sort > errors-counts-1.log

# Revert files with no change in error count
comm -12 errors-counts-0.log errors-counts-1.log | awk -F':' '{ print $1 }' | xargs hg revert --rev .~1
```

## Note to code owners

Due to the large number of errors involved in this rollout, adding `as const` was the most feasible large-scale automated solution. Ideally, a lot of these errors would be fixed by adding other appropriate type annotations. For example instead of annotating
```
type Shape = {type: 'circle', radius: number} | {type: 'square', side: number} | ...;
type ShapeKind = 'circle' | 'square' | 'triangle';
const circle = {
  type: "circle" as const,  // <-- annotation added here
  radius: 42,
};
shape.type as ShapeKind;
takesShape(circle);
```
a more appropriate annotation would be
```
const circle: Circle = { type: "circle"; radius: 42 };
...
```

Changelog: [Internal]

drop-conflicts

Reviewed By: SamChou19815

Differential Revision: D75114154

fbshipit-source-id: 67ee5673816da9625431e2a2466a1e0038386151
2025-05-21 08:42:30 -07:00
Tim Yung 84de8a075e RN: Delete @oncall Annotations (#51416)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51416

Deletes `oncall` annotations from the `facebook/react-native` repository.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D74902524

fbshipit-source-id: 32a6a5b2ff27281792d572f151e2b094d9a79029
2025-05-17 16:18:05 -07:00
Tim Yung 7d3c4c81b5 RN: Prefer Destructured Import for useCallback (#51406)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51406

Prefers using this as a destructured import instead of as a member expression of `React`.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D74894207

fbshipit-source-id: 00286b3dbaa6ce1e4d8d0f0f6c0dfef6505824c5
2025-05-16 16:33:18 -07:00
Tim Yung 3e70714cff RN: Prefer Destructured Import for useEffect (#51405)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51405

Prefers using this as a destructured import instead of as a member expression of `React`.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D74894042

fbshipit-source-id: 93fbadb32e4a1225836db9d729d7bf502ebddd84
2025-05-16 16:33:18 -07:00
Tim Yung 00108a1ac3 RN: Prefer Destructured Import for useState (#51403)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51403

Prefers using this as a destructured import instead of as a member expression of `React`.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D74891875

fbshipit-source-id: 981e85b5da84950c9e66e8d6b6496019e536711d
2025-05-16 16:33:18 -07:00
Riccardo Cipolleschi e9c8fee4ef Add Example for InteropLayer on RNTester (#51260)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51260

This is a preparatory change that adds an example to RNTester for the Fabric interop layer on iOS.
This example is needed to create a Jest E2E tests that will make sure that the Fabric Interop Layer can properly add views as subviews.

We discovered the bug thanks to react-native-maps.

## Changelog:
[Internal] - Add Example for the Fabric Interop Layer to RNTester iOS

Reviewed By: cortinico

Differential Revision: D74579737

fbshipit-source-id: 0c1bbb06790b01313cd98aa4b7152d8aba0cded3
2025-05-14 10:11:03 -07:00
Alex Hunt b731ea3d3f Internalise RNTester examples referencing unexported APIs (#51019)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51019

Follows D72228547 and D73770609.

This diff internalises (moves files from fbsource+GitHub to fbsource only) a number of RNTester examples which referenced `'react-native/src/private/'` subpaths.

In future, new components/APIs should be exported from index as `unstable_`, or added to `RNTesterListFbInternal` if they are exported from `src/fb_internal/`.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D73777092

fbshipit-source-id: d9fb0833c56f2ae580b6db62ddbbbeae774a0004
2025-05-01 09:58:30 -07:00
Ajit 87c54a7eba fix fetch of content scheme urls failing on Android (#50122)
Summary:
This PR fixes https://github.com/facebook/react-native/issues/48762
- fix creating Blobs from Android 'content://' scheme urls was failing on the js side due to [this check](https://github.com/JakeChampion/fetch/blob/ba5cf1ed2e02ebb96fa1e60b4fd2eb04071b60e4/fetch.js#L547)

## Changelog:
[ANDROID] [FIXED] - fix fetch of content scheme uris failing on Android.

Pull Request resolved: https://github.com/facebook/react-native/pull/50122

Test Plan:
Used the App here to test Android Blob creation. https://github.com/giantslogik/blob-large-file-fetch.

EDIT: Added tester to RNTester

Reviewed By: rshest

Differential Revision: D73576300

Pulled By: javache

fbshipit-source-id: 3fa5966aabd10d5fbe9f441948309c66e7113199
2025-04-24 12:39:58 -07:00
Nick Gerleman f6589177ce Fix logic around hiding chrome with deeplinks on small screen (#50806)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50806

1. `useWindowDimensions` is already returning in DIPs, my math was just wrong before
2. Playground is marking itself as a deeplink when it shouldn't be

Changelog: [internal]

Reviewed By: cortinico, joevilches

Differential Revision: D73221335

fbshipit-source-id: 32dfa9d60609faccef8e264aa46d64b79250b64d
2025-04-18 15:31:57 -07:00
nishan (o^▽^o) 1b45dc8033 feat: radial gradient js prop passing (#50268)
Summary:
Adds JS changes for radial gradient. Previous PR - https://github.com/facebook/react-native/pull/50209

## Changelog:
[GENERAL] [ADDED] - Radial gradient
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/50268

Test Plan:
- Added tests in `processBackgroundImage-test.js` in https://github.com/facebook/react-native/pull/50268
- Merge this, https://github.com/facebook/react-native/pull/50266 and https://github.com/facebook/react-native/pull/50269 and check examples in `RadialGradientExample.js`

Reviewed By: NickGerleman

Differential Revision: D71898524

Pulled By: jorge-cab

fbshipit-source-id: 39bdf0f647ba19839b6e6deb09b30a1c337e6457
2025-04-17 16:39:44 -07:00
Ritesh Kumar Shukla 3dac90006f Implementing url Methods (#49955)
Summary:
Implemented Methods in URL which were not implemented yet
The methods output are identical to outputs of window.url .

Fixes https://github.com/facebook/react-native/issues/45030

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[General][Added] URL accessors for unimplemented Methods

Pull Request resolved: https://github.com/facebook/react-native/pull/49955

Test Plan:
Code:-
<img width="558" alt="image" src="https://github.com/user-attachments/assets/a75e5429-0e03-4392-9fde-138c63b96ce5" />

Tested with Hermes
![image](https://github.com/user-attachments/assets/0075826a-df3a-4eae-a8f2-bec26be42fbf)

Tested with JSC
![image](https://github.com/user-attachments/assets/bcdbd430-5ee3-48a2-873f-7d823c9072f6)

Reviewed By: rshest

Differential Revision: D71113046

Pulled By: cortinico

fbshipit-source-id: 58093c61d2e7bb732d2f1af6b19508a100c86333
2025-03-14 05:22:48 -07:00
Rubén Norte 84a1211773 Strip all "bom" types that are actually not defined in RN (#49730)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49730

Changelog: [internal]

This removes all the types from "bom" that are actually not implemented in RN. For now, we're just stripping whole interfaces and not looking into specific methods/properties in interfaces that we do implement but not 100%.

`Performance`, `PerformanceObserver`, `MutationObserver` and `IntersectionObserver` are implemented but not stable yet, so they aren't exposed as globals in the types.

Reviewed By: huntie

Differential Revision: D70329185

fbshipit-source-id: 63bac619e100ca66b41df071df80dfa73d0f9651
2025-02-28 05:58:45 -08:00
Iwo Plaza bdc23fa2b4 Migrate files in Libraries/Interaction to use export syntax (#48933)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48933

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling

## This diff
- Updates files in Libraries/Interaction to use `export` syntax
- Appends `.default` to requires of the changed files.
- Updates the public API snapshot (intented breaking change)

Changelog:
[General][Breaking] - Files inside `Libraries/Interaction` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: huntie

Differential Revision: D68629953

fbshipit-source-id: 526b18d9b64c4b27b6e3198a9725075fa11e345a
2025-01-27 06:32:58 -08:00
Nick Gerleman 06751aa0d1 "experimental_layoutConformance" ViewProp -> "experimental_LayoutConformance" component (#48188)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48188

Yoga is full of bugs! Some of these bugs cannot be fixed without breaking large swaths of product code. To get around this, we introduced "errata" to Yoga as a mechanism to preserve bug compatibility, and an `experimental_layoutConformance` prop in React Native to create layout conformance contexts. This has allowed us to create more compliant layout behavior for XPR.

This prop was originally designed as a context-like component, so you could set a conformance level at the root of your app, and individual components could change it for compatibility. This was difficult to achieve at the time, without introducing a primitive like `LayoutConformanceView`, which itself participated in the view tree. This prop has not been the desired end-goal, since it does not make clear that it is setting a whole new context, effecting children as well!

Now that we've landed support for `display: contents`, we can achieve this desired API pretty easily.

**Before**

```
import {View} from 'react-native';

// Root of the app
<View {...props} experimental_layoutConformance="strict">
  {content}
</View>

```

**After**

```
import {View, experimental_LayoutConformance as LayoutConformance} from 'react-native';

// Root of the app
<LayoutConformance mode="strict">
  <View {...props}>
    {content}
  </View>
</LayoutConformance>

```

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D66910054

fbshipit-source-id: e6a304b5c30ad3c5845a7ce2d1021996a74c2f34
2024-12-12 14:57:04 -08:00
Sam Zhou d86412dcc6 prepare for primitive literal changes (#47943)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47943

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D66461724

fbshipit-source-id: b526ed1617667b70337472f4dad4e19f152a266b
2024-11-26 00:07:32 -08:00
Jakub Piasecki fd273f83e0 Add RNTester examples for display: contents (#47201)
Summary:
Adds a page dedicated to `display: contents` to RNTester APIs section. Those can be used to verify that it's working correctly visually.

Needs https://github.com/facebook/react-native/pull/47194

## Changelog:

[INTERNAL] [ADDED] - Added `display: contents` examples to RNTester

Pull Request resolved: https://github.com/facebook/react-native/pull/47201

Test Plan:
Row styles are ignored in new arch and TextInputs as leaf are hidden

https://www.internalfb.com/compare-screenshots-from-diff/D65248256

Reviewed By: javache

Differential Revision: D65248256

Pulled By: NickGerleman

fbshipit-source-id: 90410e1380e4cdb22cb4cac5c8c21e08a088ce69
2024-10-31 16:12:46 -07:00
Tim Yung c9ea05552f RN: Fix lint/sort-imports Errors (#47109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47109

Fixes the `lint/sort-imports` errors that are now surfaced after fixing the lint configuration.

For a couple files, I added lint suppressions instead because the unsorted import ordering is important due to interleaved calls with side effects.

Changelog:
[Internal]

Reviewed By: GijsWeterings

Differential Revision: D64569485

fbshipit-source-id: 26415d792e2b9efe08c05d1436f723faae549882
2024-10-18 04:07:02 -07:00
Shawn Dempsey 256adcab7b Add a new playground component to rntester (#46632)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46632

Changelog: [General][Added] Add Playground to RNTester for testing out features & submitting reproducers.

**Context**

- Adding the Playground from Catalyst to RNTester
- This should help folks test React Native features for a particular version

**Change**

- Add a new playground component to RNTester
- Add a new reducer action for opening an example from navbar press
- Fixed typing issues
- Add icon from this fb asset pack: https://www.internalfb.com/assets/set/facebook_icons/nucleus-beaker/variant_outline-size_24?q=beaker
- Matched background color using this imagemagick script

**dark**
```
convert input.png -fill 'rgb(178,180,186)' -colorize 100% output.png
```
**light**
```
convert input.png -fill 'rgb(81,82,84)' -colorize 100% output.png
```

Reviewed By: NickGerleman

Differential Revision: D61972594

fbshipit-source-id: 4a5523a84a6ef09d3266d5f56825907bd3fbe4b5
2024-09-25 23:29:11 -07:00
Nick Gerleman 3cd6d18aa8 Increase Example List Density (#46080)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46080

1. Force the examples to be alphabetized, where the hand-maintained list has some examples that are not
2. Remove reundant/not useful UI

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D61430910

fbshipit-source-id: 1f3e116fe81502faa7a72f2720912e26c9f04bb2
2024-08-20 16:48:38 -07:00
Nishan b99675d78a feat: linear gradient ios (#45434)
Summary:
- Adds `background` prop that supports CSS's linear gradient. Later this can be extended to support various other gradients and possibly CSS's background image (less motivation as better solutions exists for image)
- Uses `CAGradientlayer` to draw Linear Gradient layers. So it is GPU optimised under the hood.
- Style supports JS object to specify `LinearGradient`, so it can support Animated libraries.

## Changelog:
[IOS] [ADDED] - linear gradient

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/45434

Test Plan:
- Check out `processBackground-test.js` for supported syntax testcases.
- Checkout example added in ViewExample.js

Although the PR is tested well but open to any changes/feedback on the approach taken.

Android PR - https://github.com/facebook/react-native/pull/45433. Separated the PRs to keep it easier to review. Both PRs can be reviewed individually.

Reviewed By: NickGerleman

Differential Revision: D60791581

Pulled By: joevilches

fbshipit-source-id: 051088fdf68d9fe20c0c306f1f1c591cbd77f3d5
2024-08-06 13:59:33 -07:00
Nishan bd0aedc8c3 feat: linear gradient android (#45433)
Summary:
- Adds `background` prop that supports CSS's linear gradient. Later this can be extended to support various other gradients and possibly CSS's background image (less motivation as better solutions exists for image)
- Extended `CSSBackgroundDrawable` to draw Linear Gradient shader while preserving the border style support.
- Style supports JS object to specify `LinearGradient`, so it can support Animated libraries.

## Changelog:
[ANDROID] [ADDED] - linear gradient

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/45433

Test Plan:
- Check out `processBackground-test.js` for supported syntax testcases.
- Checkout examples added in `LinearGradientExample.js`

Although the PR is tested well but open to any changes/feedback on the approach taken.

iOS PR - https://github.com/facebook/react-native/pull/45433. Separated the PRs to keep it easier to review. Both PRs can be reviewed individually.

Reviewed By: joevilches

Differential Revision: D60493360

Pulled By: NickGerleman

fbshipit-source-id: 762929c4fe16d87cbbd9ebe83ecce96a9e13192c
2024-08-01 09:38:51 -07:00
Joe Vilches 944d40f204 Add mix-blend-mode effects to iOS (#45304)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45304

Add support for most keyword values of mix-blend-mode on iOS and added RNTester Example
Missing compositing operators and global values

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D59402969

fbshipit-source-id: b7e1aaed01fbf8f80e04ad0fa73d2ef63b5ad933
2024-07-15 18:10:17 -07:00
Jorge Cabiedes Acosta 261f82e897 RN tester example for mix-blend-mode (#45052)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45052

tsia

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D58760458

fbshipit-source-id: 1aadfb000d94b827ed779170254438ed4c469a52
2024-07-03 20:55:27 -07:00
Joe Vilches 88ab1ceeae RN tester example for filters (#44459)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44459

tsia

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D56857709

fbshipit-source-id: 4bbeeed89ec40ca5c9a3472578388699e47f9c9c
2024-05-08 13:39:09 -07:00
Biki-das b1576e5b1a feat: Added PixelRatio API example (#44000)
Summary:
Added the [PixelRatio](https://reactnative.dev/docs/pixelratio) API to the RN tester app on the API list examples.

## Changelog:

[General] [Added] - Add examples for the Pixel Ratio API, with all the available methods.

Pull Request resolved: https://github.com/facebook/react-native/pull/44000

Test Plan:
**iOS**

https://github.com/facebook/react-native/assets/72331432/dd481916-a8df-4a62-8f63-61936d886d33

**android**

https://github.com/facebook/react-native/assets/72331432/4d8d67dc-ddeb-4ca7-b61c-07522951f9ee

Reviewed By: NickGerleman

Differential Revision: D56135685

Pulled By: hoxyq

fbshipit-source-id: f2f4eb9e31159a4a2c660d1a864b649e537916af
2024-04-16 07:17:36 -07:00
Dmitry Rykun 1cb0a3342a Add react-native-test-library package (#43068)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43068

This diff adds `react-native-test-library` package.
It contains native module and native component example, and targets both the new and the old architecture. It has structure similar to many OSS React Native libraries, and is supposed to be used to test the integration with third-party libraries.

It is integrated with RNTester as the **OSS Library Example** screen.

{F1457510909}

**Change Background** tests native commands.
**Set Opacity** tests native props.
**Get Random Number** tests native module.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D50793835

fbshipit-source-id: ff6daefab10e6e9f13049e3013f8f63cfa8a929e
2024-04-09 11:35:43 -07:00
Saad Najmi 73664f576a feat(iOS): Implement cursor style prop (#43078)
Summary:
Implement the cursor style prop for iOS (and consequently, visionOS), as described in this RFC: https://github.com/react-native-community/discussions-and-proposals/pull/750

See related PR in React Native macOS, where we target macOS and visionOS (not running in iPad compatibility mode) with the same change: https://github.com/microsoft/react-native-macos/pull/2080

Docs update: https://github.com/facebook/react-native-website/pull/4033

## Changelog:

[IOS] [ADDED] - Implement cursor style prop

Pull Request resolved: https://github.com/facebook/react-native/pull/43078

Test Plan:
See the added example page, running on iOS with the new architecture enabled. This also runs the same on the old architecture.

https://github.com/facebook/react-native/assets/6722175/2af60a0c-1c1f-45c4-8d66-a20f6d5815df

See the example page running on all three apple platforms. The JS is slightly different because:
1. The "macOS Cursors" example is not part of this PR but the one in React Native macOS.
2. This PR (and exapmple) has went though a bunch of iterations and It got hard taking videos of every change 😅

https://github.com/facebook/react-native/assets/6722175/7775ba7c-8624-4873-a735-7665b94b7233

## Notes

- React Native macOS added the cursor prop to View with https://github.com/microsoft/react-native-macos/pull/760 and Text with https://github.com/microsoft/react-native-macos/pull/1469 . Much of the implementation comes from there.

- Due to an Apple bug, as of iOS 17.4 Beta 4, the shape of the iOS cursor hover effect doesn't render in the correct bounds (but it does on visionOS). I've worked around it with an ifdef. The result is that the hover effect will work on iOS and visionOS, but not iPad apps running in compatibility mode on visionOS.

Reviewed By: NickGerleman

Differential Revision: D54512945

Pulled By: vincentriemer

fbshipit-source-id: 699e3a01a901f55a466a2c1a19f667aede5aab80
2024-03-04 18:51:17 -08:00
Ramanpreet Nara 35308a73a5 Open source PopupMenuAndroid
Summary:
In React Native 0.75, we will remove UIManager.showPopupMenu(), UIManager.dismissPopupMenu().

To replace that API, we are introducing this <PopupMenuAndroid> component. This component works in both Fabric and Paper!

For the usage, please see PopupMenuAndroidExample.js.

Changelog: [Android][Added] - Introduce PopupMenuAndroid to replace UIManager.showPopupMenu()

Reviewed By: mdvacca

Differential Revision: D52712758

fbshipit-source-id: a87628a168d64fabbcc4d0f7b694fa639a927448
2024-01-29 18:54:14 -08:00
Kevin Gozali a47d7c54e8 Improved RNTester deeplink support to go straight to a specific example (#41981)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41981

Improved RNTester URL deeplink support to cover:
*  `rntester://example/<moduleKey>`
*  `rntester://example/<moduleKey>/<exampleKey>`

Extra details:
* For example modules that do not specify `showIndividualExamples: true`, allow deeplink URL with the specific exampleKey to only render the specific example, instead of all of them.
* Added flexibility for moduleKey: search for optional suffixes ("Index", "Example").
* Adjusted Back button action to properly go back to the root after a deeplink.
* Added `example-container` generic testID on the example wrapper component.

Changelog: [Internal]

Reviewed By: yungsters, NickGerleman

Differential Revision: D52227013

fbshipit-source-id: 4ba050592f39d6895f5124fa25c77f2d0199aa3f
2023-12-20 18:33:13 -08:00
Kevin Gozali 0363485069 RNTester: add the ability to open a specific example from incoming URL (#41642)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41642

This allows opening an example within RNTester without tapping the module card. If the app receives an openURL request with the format `rntester://example/<key>`, open that example (if exists) directly. Such URL request may come from various sources (e.g. custom test run, etc).

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D51543385

fbshipit-source-id: f9a01963cefb4602b629da0b01be6e334c28a912
2023-11-24 11:37:37 -08:00
Ruslan Shestopalyuk f4d006a785 Optional prop for RNTesterApp to provide custom test lists (#41537)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41537

# Changelog:
[Internal] -

This allows to optionally provide a custom list of component/api test clauses into `RNTesterApp`.

Reviewed By: christophpurrer

Differential Revision: D51429407

fbshipit-source-id: 3ee35f13f6156fd055f6e0cbc788b7cf01c22b36
2023-11-17 13:10:39 -08:00
Moti Zilberman d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
Gijs Weterings 67c1a806e6 Flow strictify xplat/js/react-native-github where possible (#41051)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41051

Strictifies flow to flow strict-local in files where doing that doesn't cause new flow errors.

Changelog: Internal

Reviewed By: yungsters

Differential Revision: D50369011

fbshipit-source-id: b4a5a26b839b7327a3178e6f5b35246dea365a38
2023-10-18 05:36:33 -07:00
Nick Gerleman 26b41456d2 Remove RNTester Bookmarks (#41016)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41016

This hasn't been very useful since AsyncStorage/persistence was removed, but takes up a good amount of usable screen real-estate for information in the center of the screen. Remove it.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D50297980

fbshipit-source-id: 296a377dffc89c5c203ca6264351a2a1a8281cc3
2023-10-17 10:32:34 -07:00
Adam Averay 9ca16605e0 Feature: Improvements to automaticallyAdjustKeyboardInsets (#37766)
Summary:
This is a reopened version of https://github.com/facebook/react-native/issues/35224 by isidoro98 which was closed without explanation, updated to resolve new merge conflicts and now includes an example in the RN-Tester app. Aside from that it is unchanged. Here is isidoro98's description from their original PR:

This PR builds on top of https://github.com/facebook/react-native/issues/31402, which introduced the `automaticallyAdjustsScrollIndicatorInsets` functionality. It aims to fix one of RN's longstanding pain point regarding the keyboard.

The changes provide a better way of handling the `ScrollView` offset when a keyboard opens. Currently, when a keyboard opens we apply an **offset** to the `Scrollview` that matches the size of the keyboard. This approach is great if we are using an `InputAccessoryView` but if we have multiple `TextInputs` in a `ScrollView`; offsetting the content by the size of the keyboard doesn't yield the best user experience.

## Changelog:

[iOS] [Changed] - Scroll `ScrollView` text fields into view with `automaticallyAdjustsScrollIndicatorInsets`

Pull Request resolved: https://github.com/facebook/react-native/pull/37766

Test Plan:
The videos below compare the current and proposed behaviors for the following code:

```js
<ScrollView
  automaticallyAdjustKeyboardInsets
  keyboardDismissMode="interactive">
  {[...Array(10).keys()].map(item => (
    <CustomTextInput placeholder={item.toString()} key={item} />
  ))}
</ScrollView>
```

| Current behaviour | Proposal |
|-|-|
| ![https://user-images.githubusercontent.com/25139053/200194972-1ac5f1cd-2d61-4118-ad77-95c04d30c98d.mov](https://user-images.githubusercontent.com/25139053/200194972-1ac5f1cd-2d61-4118-ad77-95c04d30c98d.mov) | ![https://user-images.githubusercontent.com/25139053/200194990-53f28296-be11-4a47-be70-cec917d7deb1.mov](https://user-images.githubusercontent.com/25139053/200194990-53f28296-be11-4a47-be70-cec917d7deb1.mov) |

As can be seen in the video, the **current behavior** applies an offset to the `ScrollView` content regardless of where the `TextInput` sits on the screen.

The proposal checks if the `TextInput` will be covered by the keyboard, and only then applies an offset. The offset applied is not the full size of the keyboard but instead only the required amount so that the `TextInput` is a **specific** distance above the top of the keyboard (customizable using the new `bottomKeyboardOffset` prop). This achieves a less "jumpy" experience for the user.

The proposal doesn't change the behavior of the `ScrollView` offset when an `InputAccessory` view is used, since it checks if the `TextField` that triggered the keyboard is a **descendant** of the `ScrollView` or not.

## Why not use other existing solutions?

RN ecosystem offers other alternatives for dealing with a keyboard inside a ScrollView, such as a `KeyboardAvoidingView` or using third party libraries like `react-native-keyboard-aware-scroll-view`. But as shown in the recordings below, these solutions don't provide the smoothness or behavior that can be achieved with `automaticallyAdjustsScrollIndicatorInsets`.

| KeyboardAvoidingView | rn-keyboard-aware-scroll-view |
|-|-|
| ![https://user-images.githubusercontent.com/25139053/200195145-de742f0a-6913-4099-83c4-7693448a8933.mov](https://user-images.githubusercontent.com/25139053/200195145-de742f0a-6913-4099-83c4-7693448a8933.mov) | ![https://user-images.githubusercontent.com/25139053/200195151-80745533-16b5-4aa0-b6cd-d01041dbd001.mov](https://user-images.githubusercontent.com/25139053/200195151-80745533-16b5-4aa0-b6cd-d01041dbd001.mov) |

As shown in the videos, the `TextInput` is hidden by the keyboard for a split second before becoming visible.

Code for the videos above:

```js
// KeyboardAvoidingView
<KeyboardAvoidingView
  style={{flex: 1, flexDirection: 'column', justifyContent: 'center'}}
  behavior="padding"
  enabled>
  <ScrollView>
    {[...Array(10).keys()].map(item => (
      <CustomTextInput placeholder={item.toString()} key={item} />
    ))}
  </ScrollView>
</KeyboardAvoidingView>
```

 ```js
// rn-keyboard-aware-scroll-view
<KeyboardAwareScrollView>
  {[...Array(10).keys()].map(item => (
    <CustomTextInput placeholder={item.toString()} key={item} />
  ))}
</KeyboardAwareScrollView>
```

Reviewed By: sammy-SC

Differential Revision: D49269426

Pulled By: javache

fbshipit-source-id: 6ec2e7b45f6854dd34b9dbb06ab77053b6419733
2023-09-15 02:34:40 -07:00
Sam Zhou 4b97484650 Rollout support for multiplatform react-native project (#39131)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39131

Docs on the new behavior: https://flow.org/en/docs/react/multiplatform

Changelog: [Internal]

Reviewed By: samwgoldman

Differential Revision: D48085422

fbshipit-source-id: daaa5a7d7d04871ab3da1ad47c6b88ef4226bdfd
2023-08-24 09:54:15 -07:00
Ramanpreet Nara 145659241a Introduce SampleLegacyModule example in RNTester (#38539)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38539

We will use this example to:
- Showcase legacy module support in the TurboModule system in RNTester
- E2E test legacy module support in the TurboModule system

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D47529295

fbshipit-source-id: b98e315741bed7740c36997d706f48e375b0c815
2023-08-21 17:58:46 -07:00
Sam Zhou 7709aadbd8 Rename examples in react-native that only has one of ios/android implementation (#38801)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38801

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D48075375

fbshipit-source-id: ac51efdb380d394f710ec8bc3ed8b098176d3cc8
2023-08-04 17:46:15 -07:00
Xin Chen 3fded52fb4 Create performance comparison example in RNTester (#38673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38673

This diff adds performance comparison examples to RNTester. In each of the comparison we have bad and good examples, which could be used for the following purposes:

- Collect common performance pitfalls
- Use as testbed on performance tools and metrics for validation hypothesis

Changelog:
[Internal] - Add performance comparison example in RNTester

Reviewed By: rshest

Differential Revision: D47821109

fbshipit-source-id: ea0242ea50724d27c7713bb116335a465e24d1a7
2023-08-01 19:08:19 -07:00
Rubén Norte f193b1774c Enable MutationObserver in RNTester (#38101)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38101

This adds a few examples of using `MutationObserver` in React Native to RNTester.

`MutationObserver` isn't yet enabled so these shouldn't be accessible normally for the time being.

Changelog: [internal]

Reviewed By: NickGerleman

Differential Revision: D46149087

fbshipit-source-id: 8374b5915b8474a17a2f2e3277a9f409f6ab8380
2023-07-03 15:34:34 -07:00